MCP vs API: What's the Difference and When to Use Which

By Updated

What is the difference between MCP and an API?

An API is an interface one program uses to call another. MCP (Model Context Protocol) is an open protocol an AI application uses to find out which tools a server has (tools/list) and to call them (tools/call). MCP doesn't replace APIs: an MCP server usually sits in front of a regular API and exposes it to the model with descriptions and schemas in one common format.

TL;DR

  • -An API is called by code a developer wrote. An MCP tool is picked by the model, and the host application sends the call. Behind the MCP server there is usually the same API.
  • -Function calling and MCP work together: function calling is how the model asks for a function to be called, MCP is where the application gets the function descriptions and where it sends the call.
  • -In the author's run, the same order came back as a 53-byte body over REST and 350 bytes over MCP. The missing-order error was HTTP 404 in REST and HTTP 200 with isError: true in MCP.
  • -Tool definitions take up context. In the author's measurement, Playwright MCP with 25 tools took 4,640 tokens (o200k_base). Anthropic's figures from November 24, 2025: 58 tools from five servers take about 55K tokens, and tool search cuts usage by 85%.
  • -A single application with a few functions of its own doesn't need MCP. It pays off when one service has to work in several AI clients.

An API is an interface one program uses to call another. MCP (Model Context Protocol) is an open protocol an AI application uses to find out which tools a server has and to call them. In the MCP vs API comparison, what matters is who decides to make the request: a developer wrote the API call, while the model picks the MCP tool. MCP doesn’t replace APIs. An MCP server usually sits in front of the same REST API and describes it to the model.

That gives a short rule. If code makes the call, use an API. If a model inside one application of yours makes the call, an API plus function calling is enough. If the same tools are needed in Claude Code, Codex, ChatGPT and your own agent, write an MCP server on top of the API.

This article draws the lines between REST, function calling and MCP. One service is built both ways and run, with responses, errors and definition sizes measured. Specification links point to revision 2026-07-28, and the data is as of November 29, 2026.

What is an API and what is MCP

An API (most often HTTP REST) answers the question of how to reach a service: address, method, parameters, response format. It doesn’t care who is calling or why. The client can be a browser, cron, a neighboring microservice or an AI agent.

MCP, in the project’s own definition, is “an open-source standard for connecting AI applications to external systems”. It standardizes a narrow stretch: how a host (Claude Code, Codex, your own agent) gets the list of tools, data and prompt templates and uses them. The specification calls tools model-controlled: the model finds and calls them on its own, though the same page recommends keeping a human able to deny the call.

Transports, primitives and client setup aren’t covered here. They’re in MCP servers explained.

MCP vs API vs function calling: comparison table

MCP gets compared with REST, although function calling is the closer relative: there, too, the model picks the call. So the table has three columns.

CriterionREST APIFunction callingMCP
Who decides to callThe developer, in codeThe modelThe model
Who executesThe API clientYour applicationThe host sends tools/call, the MCP server executes
How capabilities are discoveredDocumentation or OpenAPI, outside the protocolThe application puts schemas in the requesttools/list in the protocol itself
SchemaOpenAPI, JSON SchemaJSON Schema: input_schema at Anthropic, parameters at OpenAIJSON Schema in inputSchema, 2020-12 by default
StateUsually statelessThe application keeps the historyNo protocol session since 2026-07-28, state goes through an explicit handle in the arguments
AuthorizationAnything: key, OAuthModel API key plus your code’s permissionsOptional; an OAuth 2.1 based profile for HTTP, credentials from the environment for stdio
VersionIn the URL or a headerProvider’s API versionRevision date in every request
Context costNone until a response is passed to the modelSchemas in input tokensThe same schemas, from every connected server
Where it’s reusableAny clientOne applicationAny compatible AI client

Sources for the MCP rows: tools, authorization and the changelog of revision 2026-07-28. The function calling column was checked against the Anthropic and OpenAI documentation. The REST column describes common practice.

The state row is often out of date in other comparisons. Before revision 2026-07-28, the client started with an initialize handshake, and an HTTP server could issue an Mcp-Session-Id. Both are now gone: every request carries the version and client capabilities in _meta. In shape, a tool call is now closer to an ordinary HTTP request.

One service as REST and as MCP

The example service returns an order status. The run was done on November 29, 2026 on macOS with Python 3.13.9, mcp 2.3.0 and Starlette 1.10.0. Both servers ran on 127.0.0.1.

Shared logic and the REST version

# orders.py
ORDERS = {
    "A-1001": {"status": "shipped", "eta_days": 2},
    "A-1002": {"status": "processing", "eta_days": 5},
}


def order_status(order_id: str) -> dict[str, str | int]:
    return {"order_id": order_id, **ORDERS[order_id]}
# rest_app.py
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import JSONResponse
from starlette.routing import Route

from orders import order_status


async def get_order(request: Request) -> JSONResponse:
    try:
        return JSONResponse(order_status(request.path_params["order_id"]))
    except KeyError:
        return JSONResponse({"error": "order not found"}, status_code=404)


app = Starlette(routes=[Route("/orders/{order_id}", get_order)])

The MCP version

# mcp_app.py
from mcp.server import MCPServer
from mcp.server.mcpserver.exceptions import ToolError

from orders import order_status

mcp = MCPServer("orders", version="1.0.0")


@mcp.tool()
def get_order_status(order_id: str) -> dict[str, str | int]:
    """Return status and ETA in days for an order id, for example A-1001."""
    try:
        return order_status(order_id)
    except KeyError:
        raise ToolError("order not found")


if __name__ == "__main__":
    mcp.run(transport="streamable-http", port=8942)

The logic is the same. What’s new is a name, a description for the model, and argument types the SDK turns into JSON Schema. The description is part of the interface here: the model uses it to decide whether the tool fits. Result types matter too. In a separate run on the same SDK, structured_content stayed empty with a -> dict annotation and was filled with -> dict[str, float | str].

What came back

Start the servers in two terminals. You don’t need to install Starlette, uvicorn and httpx2 separately: they come in as mcp dependencies.

python -m uvicorn rest_app:app --host 127.0.0.1 --port 8941
python mcp_app.py

The REST request fits on one line. The tool call is a single POST with no handshake:

curl http://127.0.0.1:8941/orders/A-1001

curl http://127.0.0.1:8942/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -H 'MCP-Protocol-Version: 2026-07-28' \
  -H 'Mcp-Method: tools/call' -H 'Mcp-Name: get_order_status' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{
    "name":"get_order_status","arguments":{"order_id":"A-1001"},
    "_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28",
      "io.modelcontextprotocol/clientInfo":{"name":"raw","version":"0"},
      "io.modelcontextprotocol/clientCapabilities":{}}}}'
SituationRESTMCP
Order foundHTTP 200, 53-byte bodyHTTP 200, 350-byte body
No such orderHTTP 404, order not foundHTTP 200, isError: true, “Error executing tool get_order_status: order not found”
Argument missingNo separate case, the id is in the pathHTTP 200, isError: true, validation error text
List of capabilities/openapi.json returned 404, you have to add a description yourselftools/list: 593 bytes with the description and schemas

The MCP response is longer partly because the SDK includes the data twice: as text for the model and as an object in structuredContent. The specification recommends this for backwards compatibility. Only bodies were counted, without headers, and the ratio will be different on a large response.

The second difference matters for monitoring. A tool error arrives with HTTP 200, so a dashboard built on status codes won’t see it. That’s intentional: per the specification, execution errors are returned in the result so the model can read the text and fix its arguments. An unknown tool, for example, counts as a protocol error. In the run, SDK 2.3.0 answered it with isError: true, while the example in the specification uses code -32602, so a client shouldn’t rely on the code alone.

The third difference is the number of requests. The stock mcp.Client sent four POSTs for two tool calls: server/discover, tools/call, tools/list, tools/call. The author didn’t measure latency.

Function calling vs MCP

These mechanisms cover different links of one chain.

  1. The application requests tools/list from the MCP server.
  2. The application passes the schemas to the model in the tools parameter.
  3. The model returns a tool name and arguments.
  4. The application sends them to the server through tools/call.
  5. The result goes back to the model, and it continues the answer.

Steps 2, 3 and 5 are function calling, steps 1 and 4 are MCP. The model runs nothing itself: Anthropic’s documentation calls tool use a contract in which the model emits a structured request, and your code or Anthropic’s servers run the operation. Without MCP, steps 1 and 4 become your own code: the list of schemas lives in the repository, and the call goes to a function. The tool_use and tool_result loop itself is shown in the Claude API guide.

How an MCP schema becomes tools

The conversion takes a few lines, because both formats are built on JSON Schema:

import asyncio

from mcp import Client

from mcp_app import mcp


async def main() -> None:
    async with Client(mcp) as c:
        tools = (await c.list_tools()).tools
        anthropic_tools = [
            {"name": t.name, "description": t.description or "", "input_schema": t.input_schema}
            for t in tools
        ]
        # OpenAI Responses API: {"type": "function", "name", "description", "parameters": t.input_schema}
        block = {"id": "toolu_demo", "name": "get_order_status", "input": {"order_id": "A-1001"}}
        out = await c.call_tool(block["name"], block["input"])
        print(anthropic_tools)
        print({"type": "tool_result", "tool_use_id": block["id"],
               "content": out.content[0].text, "is_error": out.is_error})


asyncio.run(main())

The tool_use block in the example is written by hand, and no model was called in the run: it checked the schema conversion and the call execution.

Providers also offer a ready-made path without your own client. OpenAI connects a remote server with the mcp tool in the Responses API and by default asks for approval before sharing data. Anthropic has the MCP connector: as of November 29, 2026 it’s in beta, supports only tool calls, requires a public HTTP server, and isn’t eligible for zero data retention.

How many tokens tool definitions cost

REST doesn’t have this cost: the model never sees the API until you pass it a response. It does see tool definitions, and they count as billed input under function calling and MCP alike. MCP just makes it easy to pile up a lot of them. Where the cost comes from is covered in the articles on tokens and the context window.

What was countedToolsTokensSource
get_order_status from the example179author’s measurement, 11/29/2026, o200k_base
Playwright MCP 0.0.86, defaults254,640author’s measurement, 11/29/2026, o200k_base
Playwright MCP 0.0.86 with six extra groups719,969same
Slack MCP11~21KAnthropic, 11/24/2025
GitHub MCP35~26KAnthropic, 11/24/2025
GitHub, Slack, Sentry, Grafana and Splunk together58~55KAnthropic, 11/24/2025

The author’s measurements use OpenAI’s o200k_base tokenizer on JSON with the name, description and input schema. Claude’s numbers will differ, so compare the top half of the table with the bottom half only by order of magnitude. The average per tool is about 190 tokens for Playwright MCP, 740 for GitHub and 1,900 for Slack. The length of descriptions and schemas explains the spread, and you can’t estimate the cost from the tool count alone.

Anthropic’s figures come from a post dated November 24, 2025. It’s the vendor’s internal example. The tool search documentation repeats the same ~55K, so it isn’t a second independent confirmation. The Agent SDK documentation gives a different scale: 10-20K tokens for 50 tools.

Tool search and defer_loading

Anthropic’s figures from November 24, 2025 say tool search brought usage in their example down from ~77K to ~8.7K tokens before work begins; the company puts the reduction at 85%. The author made no independent measurement and found none in primary sources.

All definitions are still sent in the request, but with defer_loading: true they stay out of the initial context. The model searches the catalog, and the API inserts what it finds, up to five tools by default. Loaded definitions are billed as regular input. Deferred tools don’t change the prefix, so the prompt cache survives. Editing definitions under normal loading invalidates all of it.

Anthropic recommends tool search from 10 tools up, or when definitions exceed 10K tokens. Below that, the Agent SDK documentation says loading everything upfront is typically faster: each search adds one more round trip. In Claude Code, deferred loading of MCP tools is on by default, and only tool names and server instructions load at startup. How to keep the set of servers small is covered in MCP for AI agents.

MCP on top of a REST API

The usual scenario: you already have an API and need to give it to a model. A thin wrapper calls REST and turns status codes into text for the model.

# mcp_over_rest.py
import httpx2
from mcp.server import MCPServer
from mcp.server.mcpserver.exceptions import ToolError

mcp = MCPServer("orders-over-rest", version="1.0.0")
API = "http://127.0.0.1:8941"


@mcp.tool()
async def get_order_status(order_id: str) -> dict[str, str | int]:
    """Return status and ETA in days for an order id, for example A-1001."""
    async with httpx2.AsyncClient(base_url=API, timeout=5) as http:
        r = await http.get(f"/orders/{order_id}")
    if r.status_code == 404:
        raise ToolError("order not found")
    r.raise_for_status()
    return r.json()

In the run, the wrapper returned the same thing as the direct MCP server: data, text and error all matched. Each tool call made one GET to REST.

With REST switched off, the client got only “Error executing tool get_order_status”, with no reason. In SDK 2.3.0, ToolError text and argument validation errors go out, and other exceptions stay on the server. Internal addresses don’t leak this way, but the model doesn’t learn what to do either. Convert expected failures (timeout, 429, missing permissions) to ToolError explicitly.

A few more decisions for a wrapper (the author’s recommendations, not specification requirements):

  • One tool per task. If an answer needs the order, the delivery and the refund, one tool with three requests inside beats three tools: fewer schemas in context and fewer model steps.
  • Short responses. REST returns the whole object, the model needs only certain fields. Everything extra stays in the conversation history.
  • Writes separate from reads. Mutating operations are easier to put behind confirmation when they have their own tools.
  • REST stays the source of rules. Permissions, limits and checks live in the API, and the wrapper doesn’t duplicate them. For how to describe the API itself, see REST API design and OpenAPI.

A full server with authorization, tests and publishing is built in the MCP server in Python tutorial. It uses FastMCP 3, a standalone framework, while the code above uses the official mcp 2.x SDK.

When you don’t need MCP

  • One application and its own functions. The schemas sit next to the code and share its version. Function calling does the job without a server or transport.
  • The order of steps is known in advance. A nightly export or a webhook handler calls the API directly. Letting a model choose here adds cost and a chance of error.
  • The clients aren’t AI. MCP gives a website or a mobile app nothing.
  • There are few tools, and every request needs all of them. Search brings no gain, and the protocol overhead remains.
  • Every request counts. In the run, the stock client added two housekeeping requests to two calls; your own code hits the API once.
  • The server is third-party and unvetted. The model reads its descriptions and responses. What to check before connecting is in the MCP security guide.

When you need MCP

  • There are several clients. One server connects to Claude Code, Codex and your own agent instead of being rewritten for each.
  • An existing server fits. For example, with Playwright MCP you don’t have to wrap a browser yourself.
  • Different teams are involved. The service owner changes the schema on their side, and clients get it through tools/list. The downside: a description can change without your review. For such cases, the beta MCP connector can pin the tool list.
  • The model loop isn’t yours. In ChatGPT and other finished applications you can’t insert your code into that loop, but you can connect a server. For an agent with terminal access there’s a simpler option: a CLI on top of the API.

Keep versions in mind when you switch. In the author’s run, one HTTP endpoint on mcp 2.3.0 served both a new client (2026-07-28) and an old one on mcp 1.30.0 (2025-11-25). A new client in auto mode also connected to an old server by falling back to initialize. With the version pinned to 2026-07-28, the very first request to the old server failed with “Missing session ID”.

Summary: what to choose

  1. A developer writes the request: API.
  2. The model picks the request, there’s one application and few functions: API and function calling.
  3. Ten tools or more, or their definitions exceed 10K tokens: add tool search, with or without MCP.
  4. Several AI clients need the tools: an MCP server on top of the API.

It’s easier to start with the API, because you’ll need it in any case. The wrapper from the example took under 20 lines, and you can add it when a second client shows up.

Frequently Asked Questions

Does MCP replace REST APIs?
No. An MCP server usually calls an existing API and translates it into tools for the model. Websites, mobile apps and background jobs still need the API, because a developer writes their requests and no model picks them.
What is the difference between MCP and function calling?
Function calling describes the exchange between the application and the model: the application passes function schemas, the model returns a name and arguments. MCP describes the exchange between the application and a tool server: tools/list returns the schemas, tools/call runs the call. An application with MCP uses both mechanisms at once.
Do I need MCP if I have only one application?
Usually not. If the functions live in the same code as the model call, function calling and direct API requests are enough. MCP adds a process or server, a transport and authorization. It becomes useful when a second client needs the same tools, or when an existing third-party server fits.
How many tokens does an MCP server use?
There's no universal number: it depends on the tool count and schema length. In the author's measurement, Playwright MCP 0.0.86 took 4,640 tokens with 25 tools and 9,969 with 71 (o200k_base tokenizer, Claude's numbers differ). Anthropic cites about 26K tokens for 35 tools on the GitHub server (example from November 24, 2025).
What are tool search and defer_loading?
Tool search lets the model search a tool catalog instead of getting every definition up front. The defer_loading: true parameter keeps a definition out of the initial context, and the API inserts it once the model has found the tool through search. In Claude Code, deferred loading of MCP tools is on by default.
Does MCP only work with Claude?
No. The OpenAI Responses API connects remote servers through a tool of type mcp, and both Codex and Claude Code work with local and remote servers. Clients support different feature sets: as of November 29, 2026, the MCP connector in the Messages API supports only tool calls.
Is MCP more secure than a regular API?
No, it has its own threat model. The model reads tool descriptions and tool results, so a third-party server can influence its behavior with text. The specification requires clients to treat tool annotations as untrusted unless the server is trusted, and recommends that a human be able to deny a call.