An API is how one program asks another to do something. MCP (Model Context Protocol) is how an AI application finds out which of those requests it is allowed to make, and makes them through one standard interface. Most MCP servers are thin wrappers around an API that already exists, so the real question is rarely "MCP or API". It is "should my agent call the API directly, or through an MCP server in front of it?"
This guide answers that with the architecture, the trade-offs that show up in production (tokens, credentials, maintenance), and one real task built both ways.
What is an API?
An API (application programming interface) is a contract: send a request in this shape to this address, get a response in that shape back. A weather service exposes GET /forecast?city=Berlin. Stripe exposes POST /v1/payment_intents. Your banking app, your smart thermostat and a Slack bot all run on calls like these.
Most web APIs today are REST over HTTP and return JSON. The API does not care who calls it. A mobile app, a cron job and an AI agent all look the same to the server: an authenticated HTTP request. The provider usually describes the endpoints in human-readable docs and, often, in a machine-readable OpenAPI file.
If you want the full background, see What Is an API?.
What is MCP?
MCP is an open protocol for connecting AI applications to tools and data. Anthropic introduced it in November 2024 to solve a specific problem: every AI app needed custom glue code for every tool, so ten apps and ten tools meant up to a hundred integrations. With MCP, a tool is wrapped once as an MCP server, and any MCP-compatible client can use it. In December 2025 Anthropic handed MCP to the Agentic AI Foundation under the Linux Foundation, so it is no longer a single-vendor spec.
The pieces:
- Host and client. The AI application (Claude Desktop, ChatGPT, Cursor, a custom agent) runs an MCP client that connects to one or more servers.
- Server. A program that exposes capabilities. It can run locally as a subprocess over stdio, or remotely over Streamable HTTP, the two transports defined in the current specification.
- Primitives. Servers offer tools (actions the model can call), resources (data the app can read) and prompts (reusable templates).
- Wire format. Messages are JSON-RPC 2.0. The client calls tools/list to learn what exists, then tools/call to run one.
The key detail is discovery. A client does not need to know in advance what a server can do. It connects, asks, and gets back each tool's name, description and JSON Schema for its inputs. The model reads those descriptions and decides when to call what.
How MCP and APIs relate
Picture the request path for "check my latest email" in both setups.
In the direct version, you write the tool definition yourself, hand it to the model with function calling, and execute the HTTP request when the model asks for it. In the MCP version, someone else already wrote that definition and that HTTP call, packaged them as a server, and your client loads them at runtime.
So MCP sits on top of function calling (also called tool calling), which every major model API supports through a tools parameter. MCP adds three things around it: a standard way to discover tools, a standard transport, and a standard place for auth to live.
That is also why the Reddit-favourite question "will MCP replace APIs?" has a short answer: no. Without the API, the MCP server has nothing to call.
MCP vs API: side-by-side comparison
When to call the API directly
You own the code and the job is narrow. A support bot that only ever looks up orders needs one or two functions. Writing them yourself is faster than finding, vetting and running a server.
Latency and control matter. A direct call skips the MCP hop and the server's own logic. You choose retries, timeouts, caching and exactly which fields come back.
The work is deterministic. If the same three calls happen in the same order every time, that is a script, not an agent decision. Code it. Let the model only handle the parts that need judgment.
You don't want another process. A local MCP server is a dependency you install, update and monitor. When the spec or the server changes, that is your problem too.
When MCP is worth the extra layer
The same tool must work in several AI clients. If your users run Claude Desktop, ChatGPT and Cursor, one MCP server covers all three. Writing three integrations does not scale.
The person using the agent is not the developer. A non-developer can paste a server URL into a connector screen. They cannot write function-calling code. This is the main reason SaaS companies ship MCP servers.
You want credentials out of the model's environment. In a well-built server, the API key or OAuth token lives in the server process. The model sees only tool names and results, and the client can block some tools or ask for confirmation before writes. Developers in a long Hacker News thread on whether MCP is dying kept coming back to this point. It is easier to lock an agent to a fixed set of MCP tools than to restrict a shell.
The toolset changes over time. Because the client discovers tools at connect time, the server can add a tool and every client sees it without a redeploy.
The cost nobody puts in the comparison table: context
Every tool an MCP client loads is described to the model in text: name, description, input schema. Those tokens are paid on every request, whether the tool is used or not. Connect five servers with twenty tools each and the model reads a hundred tool definitions before it reads your question.
Results add up too. If a tool returns a 10,000-row spreadsheet, all of it passes through the model's context unless something filters it first.
Practical rules that follow:
- Connect only the servers a task needs. Turn the rest off.
- Prefer servers with a few general tools over servers with fifty narrow ones.
- For bulk data, filter in code before the result reaches the model.
- With a direct API, you choose the tool surface yourself, so the context cost stays small by default.
MCP vs API vs CLI: the third option
A coding agent with a shell (Claude Code, Codex, OpenClaw, Hermes) can just run a command-line tool. gh pr list, aws s3 ls and curl already work, and models have seen millions of examples of them in training. There are no tool definitions in context. The agent runs --help when it needs to.
The CLI wins for developers on their own machine. It loses when the agent runs in a chat app with no shell, or when you need hard limits on what it can touch.
How to convert an API into an MCP server
If you already have an API, an MCP server is a wrapper around it. The steps:
- Pick the tools. Map user tasks, not endpoints. "Send an email" is one tool, even if it takes two API calls. Fewer, well-described tools beat a one-to-one copy of your REST surface.
- Write descriptions for the model. The description is the model's only documentation. Say when to use the tool, what the inputs mean and what it returns.
- Define input schemas. JSON Schema for every parameter, with required fields and enums where they apply.
- Choose a transport. stdio for a local server that runs on the user's machine; Streamable HTTP for a hosted one.
- Handle auth. For a remote server, the spec expects OAuth 2.1. Keep the upstream API credential inside the server.
- Return errors the model can act on. "401" tells a model nothing. "Token expired, call login first" lets it fix itself.
The official SDKs (TypeScript, Python and others, linked from modelcontextprotocol.io) handle the JSON-RPC plumbing, so most of the work is steps 1 to 3.
Security: both paths share the same weak spot
MCP is not more or less safe than an API by itself. Three risks apply to both:
- Over-broad credentials. A token with full account access gives the agent full account access, however you connect it. Use the narrowest scope the provider offers.
- Untrusted servers. Installing a third-party MCP server means running someone else's code with your credentials. Read it or use servers from the vendor.
- Prompt injection through results. Any tool output, an email, a web page, a ticket, can contain text that tries to steer the model. The protocol cannot fix that; your tool permissions can. See What Is a Prompt Injection Attack? for how this plays out with email.
One task, built both ways: giving an agent an inbox
Comparisons usually stop at tables. Here is the same job, "read the agent's latest emails", built with a direct API and with MCP, using Atomic Mail Agentic, an email API made for AI agents. It exposes the same inbox through REST + JMAP, a local MCP server and a hosted MCP server, so the difference is only the integration layer.
Option 1: direct API with function calling
Atomic Mail speaks JMAP (RFC 8620/8621), a JSON-over-HTTP mail protocol. After authentication you have a short-lived capability token, the JMAP apiUrl and your accountId (all from GET https://api.atomicmail.ai/.well-known/jmap). Reading mail is two JMAP calls: find the inbox, then query and fetch messages in one batch.
When the model returns a tool call, your loop runs read_latest_emails and sends the result back. You own the code, the token refresh (the capability token lives about two minutes) and the error handling. In exchange: one tool in context, no extra process, full control. The full auth flow is in the code examples.
Option 2: local MCP server
Same inbox, no HTTP code. Add the server to any MCP host config:
The server exposes three tools: register, jmap_request and help. The agent calls register with a username and gets its own @atomicmail.ai address. Proof-of-work sign-up and token rotation happen inside the server, so there is no API key for a human to create first. Reading the inbox is one tool call with a bundled preset:
Option 3: hosted MCP server
For chat apps that can't run npx, the hosted server lives at https://mcp.atomicmail.ai/mcp. Paste the URL into the Claude or ChatGPT connector screen and sign in with OAuth. It exposes higher-level tools (read_inbox, read_message, search_messages, send_email, reply_to_message), and the OAuth token never reaches the mail backend: each call is exchanged for a short-lived capability scoped to one inbox. Message bodies come back wrapped as untrusted content, which helps against injection through email.
Which one wins here?
Same inbox, same JMAP underneath. That is the honest answer to MCP vs API: pick the layer by who runs the agent, not by which one is newer.
If you want to try any of the three paths, Atomic Mail Agentic is in open alpha: free, no card, and an agent can get its own inbox in about 30 seconds. Get started with the docs or follow the 30-second inbox tutorial.
FAQ
What is the difference between MCP and an API?
An API is an interface a program calls to get work done. MCP is a protocol that lets AI applications discover and call such interfaces through one standard. Most MCP servers call an API underneath.
Will MCP replace APIs?
No. MCP needs an API, a database or some other system behind it to do anything. It replaces the custom glue code between AI apps and APIs, not the APIs themselves.
Is an MCP server just an API wrapper?
Usually, yes. A good one adds more than a wrapper: tool descriptions written for models, task-level tools instead of raw endpoints, auth handling and errors the model can recover from.
Can an AI agent call an API without MCP?
Yes. Every major model API supports function calling: you describe a function, the model asks to call it, your code makes the HTTP request. That is how agents used APIs before MCP existed.
Is ChatGPT an API?
ChatGPT is an app. OpenAI sells model access separately through its API. ChatGPT can also act as an MCP client: it connects to remote MCP servers through its connectors.
How do I convert an API to MCP?
Choose a few task-level tools, write clear descriptions and JSON Schemas for them, implement them with an official MCP SDK, and pick stdio (local) or Streamable HTTP (hosted) as the transport.
Is MCP slower than calling an API directly?
There is one extra hop, which is small for a local server. The bigger cost is tokens: every loaded tool definition is sent to the model on each request.
Is MCP more secure than an API?
Not automatically. MCP makes it easier to keep credentials away from the model and to limit an agent to a fixed set of tools. A badly written or untrusted server is still a risk.
What is the difference between MCP and REST?
REST is an architectural style for APIs, built on HTTP methods and URLs. MCP is a protocol built on JSON-RPC 2.0, designed for AI clients to discover tools at runtime. An MCP server often calls a REST API underneath.
MCP vs API vs CLI: which should a coding agent use?
If the agent has a shell and runs on a developer's machine, a CLI is often the cheapest option because nothing is loaded into context until it is needed. Use MCP when there is no shell or when you need strict limits on what the agent can do.
What is the difference between MCP and A2A?
MCP connects an agent to tools and data. A2A (Agent2Agent) connects agents to other agents. They solve different problems and can be used together. See Top 5 A2A Services.
