MCP vs API: When You Need Which, With Real Benchmarks
说明与用途
REST API 与 MCP 服务器比较:测量了延迟、吞吐量和模型令牌使用。REST 更快,MCP 允许模型动态发现工具。
问题
Choosing between a REST API and a Model Context Protocol (MCP) server for exposing service operations to code or AI models.
结果
REST API latency p50 76 µs, throughput 66,486 req/s; MCP server latency p50 424 µs (848 µs when wrapping REST), throughput 4,595 req/s. MCP adds token cost for each tool definition but enables AI models to discover and call tools dynamically.
工作流
- 1. Implement service operations with a shared Zod schema.
- 2. Expose operations as REST endpoints (e.g., GET /api/projects/:slug).
- 3. Register the same operations as MCP tools using the TypeScript SDK.
- 4. Run benchmark tests measuring latency, throughput, bytes and model tokens for both implementations.
- 5. Compare results and decide which interface to expose to which callers.
证据
Latency in my test (p50) REST API 76 µs, MCP server 424 µs (848 µs when it wraps the REST API)
Use a REST API when your own code is the caller: web and mobile apps, cron jobs, webhooks, service-to-service calls and fixed agent pipelines you control.
Add an MCP server when AI clients you don't control (Claude, ChatGPT, Cursor, VS Code, Copilot) should use your service, or when the model must pick tools at runtime.
- 记录日期: 2026-10-18T05:55:59.145Z