Comparison
MCP vs API: What Model Context Protocol Adds
Call an API directly when your own code decides what to call: a web app, a batch job, a service. Put an MCP server in front of it when an AI application should discover and call those operations itself, across many hosts, with no per-app integration. MCP does not replace the API; it usually wraps it.
Last updated · By Rohit Ghumare
MCP vs API at a glance
"API" here means the usual case: an HTTP API with its own paths and payloads, called by code a developer wrote.
| MCP | API (HTTP/REST) | |
|---|---|---|
| What it is | An open standard for connecting AI applications to external systems | Any interface one program exposes to another |
| Who decides the call | A model, inside a host application | A developer, when writing the code |
| Discovery | At runtime: tools/list, resources/list, prompts/list, server/discover | Ahead of time: the developer reads the docs or a schema |
| Message format | JSON-RPC 2.0 with a fixed set of methods | Chosen by each API: paths, verbs, payloads |
| What is exposed | Tools (actions), resources (data), prompts (templates) | Endpoints |
| Transport | Stdio for local servers; Streamable HTTP for remote ones | HTTP |
| Result shape | A content array (text, image, audio, resource links), optionally structuredContent | Whatever the API defines, usually JSON |
| Per-request metadata | Protocol version and client capabilities in _meta on every request | Whatever the API defines |
| Authentication | Over HTTP: bearer tokens, API keys or custom headers; the docs recommend OAuth | Whatever the API defines |
| Integration cost | One server works in every host that speaks MCP | One client integration per consuming app |
The MCP column comes from the Model Context Protocol documentation listed in this page's sources, read on 2026-12-04. It describes protocol version 2026-07-28; versions through 2025-11-25 used an initialize handshake with connection-scoped capabilities. The client list and the version string in the code below are from the same reading.
When to choose each
Choose MCP when
- The caller is an AI application and the model should choose which operation to run.
- You want the same integration to work in several hosts. The MCP docs list Claude, ChatGPT, Visual Studio Code and Cursor among the clients that support it.
- The tool list changes. A host can call
tools/listagain and pick up new tools without a code change. - You want to hand the model data and templates as well as actions: resources and prompts are separate primitives from tools.
- Several agents in your company need the same internal systems, and you want one place to enforce access.
Choose a direct API call when
- Ordinary code is the caller. No model is choosing, so runtime discovery adds nothing.
- One application, one model and a handful of functions you own. Function calling plus a direct call is simpler.
- You need exact control of the request: headers, pagination, retries, streaming formats.
- The call is on a hot path where another hop and another serialization step are not worth it.
Use both when
This is the normal shape. Keep the API as the source of truth for every caller, and add a thin MCP server that exposes the few operations an AI application should have, described for a model.
Code: one example per side
Both scripts use only the Python standard library and run as-is.
A direct API call. The caller's code already knows the path and the parameter name.
import json
import threading
import urllib.request
from http.server import BaseHTTPRequestHandler, HTTPServer
class WeatherAPI(BaseHTTPRequestHandler):
def do_GET(self):
body = json.dumps({"city": "Pune", "temp_c": 31}).encode()
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.end_headers()
self.wfile.write(body)
def log_message(self, *args):
pass
server = HTTPServer(("127.0.0.1", 0), WeatherAPI)
threading.Thread(target=server.handle_request).start()
url = f"http://127.0.0.1:{server.server_port}/v1/weather?city=Pune"
with urllib.request.urlopen(url) as response:
print(json.load(response))
server.server_close(){'city': 'Pune', 'temp_c': 31}The same operation behind MCP-shaped messages. The client knows nothing about the server in advance: it lists the tools, then calls one by the name it was given. This is an in-process sketch of the message shapes, not a full server; the Building an MCP Server lesson adds a real transport.
import json
META = {
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientCapabilities": {},
}
TOOLS = [{
"name": "weather_current",
"description": "Current temperature for a city",
"inputSchema": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
}]
def server(request):
params = request["params"]
if request["method"] == "tools/list":
result = {"resultType": "complete", "tools": TOOLS, "ttlMs": 0, "cacheScope": "private"}
elif request["method"] == "tools/call" and params["name"] == "weather_current":
text = f"{params['arguments']['city']}: 31 C"
result = {"resultType": "complete", "content": [{"type": "text", "text": text}]}
elif request["method"] == "tools/call":
error = {"code": -32602, "message": f"Unknown tool: {params['name']}"}
return {"jsonrpc": "2.0", "id": request["id"], "error": error}
else:
error = {"code": -32601, "message": "Method not found"}
return {"jsonrpc": "2.0", "id": request["id"], "error": error}
return {"jsonrpc": "2.0", "id": request["id"], "result": result}
def call(request_id, method, **params):
request = {"jsonrpc": "2.0", "id": request_id, "method": method, "params": {**params, "_meta": META}}
return server(json.loads(json.dumps(request)))
tools = call(1, "tools/list")["result"]["tools"]
print([tool["name"] for tool in tools])
answer = call(2, "tools/call", name=tools[0]["name"], arguments={"city": "Pune"})
print(answer["result"]["content"][0]["text"])['weather_current']
Pune: 31 CIn a real host, the model sits between those last two steps: it reads the tool descriptions from tools/list and decides whether to call weather_current and with which arguments.
Common mistakes
- Thinking MCP replaces the API. The server still has to call something. Build the API first; wrap it second.
- Mirroring every endpoint as a tool. The model reads every tool description. Expose a few task-shaped tools with clear names and typed inputs, not your whole route table.
- Treating client identity as a credential. The client name in
_metais self-reported, useful for display and debugging. Authenticate and authorize each operation before its handler runs. - Relying on connection state. On protocol version 2026-07-28, do not assume an earlier request told you the version or capabilities. Read them from the current request.
- Returning instructions inside data. Tool results and resource content are data from an outside system. A host should not treat text inside them as commands.
- Skipping gates on consequential tools. Tools that send, delete or spend need confirmation or tighter scopes. A read-only annotation is not enough for a speculative call: a read can expose private records or send query text to an outside system, so check authorization and where the data goes first.
- Confusing MCP with function calling. Function calling is the model-to-app half. MCP is the app-to-server half. Most agents use both.
Frequently asked questions
Is MCP just another API?
MCP is a protocol with a fixed set of methods, so in that sense it is an API. What it adds is a shared contract for AI applications: every server answers the same discovery and call methods, so a host can use a server it has never seen without anyone writing integration code for it.
Does MCP replace REST APIs?
No. An MCP server usually sits in front of an existing API, database or file system and exposes parts of it as tools, resources and prompts. Your web app, mobile app and other services keep calling the API directly. MCP is the door you add for AI applications.
What is the difference between MCP and function calling?
Function calling is how a model asks for a tool: the app sends tool definitions and the model returns a structured call. MCP is how the app gets those definitions and runs the call, by listing and calling tools on a server. With plain function calling, the app developer describes and executes every tool.
When should I not use MCP?
Skip it when no model is choosing the call. A scheduled job, a web page or a payment service that always calls the same endpoint gains nothing from runtime discovery. Also skip it for one app with a few tools you own, where function calling plus a direct API call has fewer moving parts.
Is MCP stateful or stateless?
As of protocol version 2026-07-28, MCP is stateless. Every request carries the protocol version and the client's capabilities in its _meta field, so a server can process each request on its own. Servers advertise versions and capabilities through the server/discover method. Versions through 2025-11-25 used an initialize handshake, and servers on those versions still exist.
Learn it by building
These free lessons build the stack from the model outward:
- The Tool Interface — Why Agents Need Structured I/O: the describe, decide, execute, observe loop under every tool protocol.
- Function Calling Deep Dive — OpenAI, Anthropic, Gemini: how a model asks for a tool.
- Tool Schema Design — Naming, Descriptions, Parameter Constraints: naming and typing tools so a model picks the right one.
- MCP Fundamentals: Stateless Requests and JSON-RPC: the message envelope, per-request metadata and discovery.
- Building an MCP Server: Stateless Python and TypeScript: a working server in Python and TypeScript.