Guide protocol/
MCP vs REST: why agents don't just call your API
A REST API is a contract developers code against. An MCP server is a contract AI hosts read at runtime. Most MCP servers sit in front of an API rather than replacing it.
Short answer
MCP doesn't replace a REST API. A REST API is a contract a developer reads and writes code against; an MCP server is a contract an AI host reads at runtime. The host calls tools/list, gets each tool's name, description and JSON Schema, gives them to the model, and sends tools/call when the model picks one. Most MCP servers call an API underneath. Build one when people should reach your system from AI hosts, not only from your own code.
Checked against: MCP architecture overview, MCP Tools spec, MCP Authorization spec, MCP Security Best Practices and Anthropic’s tool-writing guidance, December 6, 2026.
Run by us: no. JSON examples are copied from the MCP specification.
How is an MCP server different from a REST API?
A REST API is designed for a developer who reads its documentation and writes integration code, while an MCP server is designed for an AI host that discovers its tools at runtime and lets a model decide when to call them.
| REST API | MCP server | |
|---|---|---|
| Who reads the contract | A developer, before writing code | The AI host and the model, at runtime |
| Interface | Designed per API: its own paths, verbs and payloads | The same JSON-RPC 2.0 methods on every server: tools/list, tools/call, resources/read, prompts/get |
| Descriptions are written for | People | The model, which picks tools from their descriptions |
| Who decides to make a call | Your code | The model; the spec says a human SHOULD be able to deny it |
| Errors | Defined by each API | Protocol errors as JSON-RPC errors; tool failures as results with isError: true |
| Authorization | Defined by each API | An OAuth 2.1 based flow for HTTP servers; environment credentials for stdio servers |
| Who can use it | Code written for this API | Any MCP host |
The MCP column reflects the specification as of December 6, 2026 (revision 2026-07-28). The REST column is deliberately loose, because every REST API makes its own choices. That variation is the point: an AI host can’t know your paths and payloads unless someone writes an integration for that host.
Why can’t an agent just call my REST endpoints?
An agent can, if someone writes that integration into every AI host; MCP exists so that nobody has to.
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"resultType": "complete",
"tools": [
{
"name": "get_weather",
"title": "Weather Information Provider",
"description": "Get current weather information for a location",
"inputSchema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name or zip code"
}
},
"required": ["location"]
},
"icons": [
{
"src": "https://example.com/weather-icon.png",
"mimeType": "image/png",
"sizes": ["48x48"]
}
]
}
],
"nextCursor": "next-page-cursor",
"ttlMs": 300000,
"cacheScope": "public"
}
}
That tools/list response, from the Tools spec, is everything a host needs to use the tool. The host passes the name, description and schema to the model, and the architecture overview says it then “intercepts the tool call, routes it to the appropriate MCP server” when the model asks.
Compare that with a REST API. A developer has to read the docs, pick endpoints, write the calls and ship them inside one product. Anthropic’s MCP launch post named that cost: “Every new data source requires its own custom implementation, making truly connected systems difficult to scale” (Anthropic). The MCP site lists Claude, ChatGPT, VS Code and Cursor among its clients and calls the result “build once and integrate everywhere” (modelcontextprotocol.io).
Where does an MCP server sit relative to my API?
An MCP server usually sits in front of your API as an adapter, with its own credentials on each side.
AI host (MCP client) --token for the MCP server--> your MCP server --its own credential--> your REST API
The MCP docs say remote servers “can integrate with various services such as project management tools, documentation systems, code repositories, and any other API-enabled service” (MCP docs). Your API keeps serving your own code and partners. The MCP server serves AI hosts.
The two credentials in the diagram are a rule, not a suggestion. The Authorization spec says MCP servers “MUST only accept tokens that are valid for use with their own resources” and “MUST NOT accept or transit any other tokens.” Forwarding the client’s token to your API is the token passthrough anti-pattern.
If your MCP server connects users to a third-party API with one static OAuth client ID, the Security Best Practices page says it “MUST implement per-client consent.” Without it, an attacker can use the proxy as a confused deputy and obtain an authorization code without the user’s consent.
How should I map endpoints to tools?
Map tools to tasks an agent performs, not one tool per endpoint.
| Endpoint-shaped tool | Task-shaped tools |
|---|---|
list_contacts |
search_contacts or message_contact |
That example is from Anthropic’s engineering post, which warns about “tools that merely wrap existing software functionality or API endpoints” and says “Too many tools or overlapping tools can also distract agents from pursuing efficient strategies” (Anthropic). Its advice:
- Build “a few thoughtful tools targeting specific high-impact workflows.”
- Return “only high signal information back to agents.”
- Use “some combination of pagination, range selection, filtering, and/or truncation” for large responses.
- Group related tools under common prefixes, such as
asana_searchandjira_search.
The Tools spec adds naming rules: names SHOULD be 1 to 128 characters, case-sensitive, unique within a server, and limited to ASCII letters, digits, _, - and ..
REST habits around state need rethinking too. As of revision 2026-07-28, MCP has no protocol-level session. A server that needs state across calls returns an explicit handle and accepts it as an argument later:
// → tools/call
{ "name": "create_basket", "arguments": {} }
// ← result
{
"content": [{ "type": "text", "text": "Created basket bsk_a1b2c3" }],
"structuredContent": { "basket_id": "bsk_a1b2c3" }
}
// → tools/call
{
"name": "add_item",
"arguments": { "basket_id": "bsk_a1b2c3", "sku": "..." }
}
The spec says the model “is responsible for carrying basket_id forward.” For authenticated servers, the server should check the caller’s authorization against the handle on every call.
How do MCP errors differ from HTTP status codes?
MCP separates protocol errors, returned as JSON-RPC errors, from tool execution errors, returned as normal results with isError: true so the model can read them and retry.
{
"jsonrpc": "2.0",
"id": 4,
"result": {
"resultType": "complete",
"content": [
{
"type": "text",
"text": "Invalid departure date: must be in the future. Current date is 08/08/2025."
}
],
"isError": true
}
}
The Tools spec reserves JSON-RPC errors for problems like an unknown tool or a malformed request. API failures, input validation errors and business logic errors go in the result, and clients SHOULD pass them to the model “to enable self-correction.” When your MCP server gets a 4xx from your REST API, translate it into a sentence the model can act on.
When is the REST API enough on its own?
The REST API is enough when no AI host needs to discover and call your system.
| Situation | What to build |
|---|---|
| Only your own app calls the API, possibly through a model’s function calling | Nothing new; see function calling vs MCP |
| Batch jobs, pipelines and service-to-service calls | Nothing new; no model is choosing calls |
| A step must run the same way every time | Keep it in code that calls the API directly |
| People want your system inside Claude Code, VS Code, ChatGPT or Cursor | An MCP server |
| Each user should act with their own permissions inside the AI host | An HTTP MCP server using the OAuth-based authorization flow |
What security work does an MCP server add?
An MCP server takes calls chosen by a model, so the spec puts input validation, access control, rate limiting and output sanitization on the server.
| Requirement | Source |
|---|---|
| Servers MUST validate all tool inputs, implement access controls, rate limit tool invocations and sanitize tool outputs | Tools spec |
| Servers MUST validate that access tokens were issued for them | Authorization spec |
| Servers MUST NOT treat possession of a state handle as authentication | Security Best Practices |
Your tool descriptions also become part of the attack surface. The MCP project’s Local Server Security guide puts it directly: “Tool names and descriptions are instructions your model reads.” Keep each description about the tool’s job: the same guide tells users to remove any server whose descriptions carry instructions unrelated to the tool. See tool poisoning.
What to read next
Sources
Changelog
- First published.
Cite this page
Agents for Devs. "MCP vs REST: why agents don't just call your API." Published Dec 6, 2026. https://agentsfordevs.com/guides/mcp-vs-rest - Page: https://agentsfordevs.com/guides/mcp-vs-rest
- Markdown version: https://agentsfordevs.com/guides/mcp-vs-rest.md
- Reuse: quote or summarize with a link to this page. Reuse terms
Cite one section
- How is an MCP server different from a REST API?
- Why can’t an agent just call my REST endpoints?
- Where does an MCP server sit relative to my API?
- How should I map endpoints to tools?
- How do MCP errors differ from HTTP status codes?
- When is the REST API enough on its own?
- What security work does an MCP server add?
- What to read next