5 December 2026 · 7 min read · Download as PDF

MCP vs API: is it your code asking, or your AI?

An API lets your code call a service. The Model Context Protocol (MCP) lets an AI app find out what a service can do, then use it, often by calling that same API. See one order lookup done both ways, with code you can run, and when you need which.

Two Space Llamas stare each other down in a spaceship: one in an orange suit, the other in a yellow suit holding a red net.

An API lets your code call a service. The Model Context Protocol (MCP) lets an AI app find out what a service can do, then use it. They aren't rivals: an MCP server often does its work by calling an API. Below, the same order lookup is done both ways, with code you can run, so you can see what MCP adds and when you can do without it.

TL;DR

  • API: your code asks. A developer reads the documentation, picks the endpoint and writes the call. The choice is made before the code runs.
  • MCP: your AI asks. The AI app gets a list of tools from an MCP server, and the model usually picks one to suit what you asked for.
  • MCP doesn't replace APIs. It gives AI apps one standard way to reach them, along with files, databases and other tools.
  • Build an API when software needs your service. Add an MCP server when you want AI apps you didn't write to use it too.
  • Skip MCP when the steps are fixed, or when one app of your own needs only a few tools.

The same question, asked both ways

The question is "Where is order 1042?" The shop has a small API with one endpoint, GET /orders/{id}.

With the API

You know the endpoint exists, so you call it:

Shell
curl http://127.0.0.1:3690/orders/1042
Text
{"id":1042,"status":"shipped","carrier":"Llama Express","eta":"2026-12-08"}

The decision was made when you wrote that line. Your code knows the address, the order number and what to do with the answer.

With MCP

Now a customer types "where's my order, 1042?" into an AI assistant. Nobody has written code for that sentence, so the assistant first needs to know what it can do. It asks the MCP server with a tools/list request, and the reply lists each tool. This is the entry for ours, trimmed:

Text
{  "name": "get_order",  "description": "Look up one order by its number: status, carrier and delivery date.",  "inputSchema": {    "type": "object",    "properties": {      "id": { "type": "integer", "description": "Order number, such as 1042" }    },    "required": ["id"]  }}

The model reads that description, matches it to the question and chooses get_order. The assistant sends the call (trimmed to the parts that matter):

Text
{  "method": "tools/call",  "params": { "name": "get_order", "arguments": { "id": 1042 } }}

The MCP server then calls GET /orders/1042, the same endpoint as before, and returns the same order. The API still does the work. What changed is who decided to call it, and when.

Who's who in MCP

  • Host: the AI app you use, such as Claude Code or Visual Studio Code.
  • Client: a part inside the host that talks to one MCP server. Three servers means three clients.
  • Server: a program that offers tools (actions), resources (data to read) and prompts (reusable templates). It can run on your own machine or remotely.

The model never talks to the server itself. It asks for a tool, and the host decides whether to run it. That's where an app can stop and ask you first.

The same AI agent, built both ways

An AI agent can use your services with or without MCP. The model picks a tool either way, and the same APIs do the work. The difference is where the connections live.

API vs MCP: how an AI agent reaches your services. Top, the API approach: inside your agent, the AI model uses your Orders code and your Payments code, and each calls its own API. Bottom, the MCP approach: inside any AI app that supports MCP, the AI model uses MCP clients, which connect to an Orders MCP server and a Payments MCP server outside the app. Each server calls its own API.

Open this diagram in archhy, our sister product for architecture diagrams, and press Make a copy in archhy to edit your own.

  • Calling the APIs directly: you write the code for each API inside your agent. A second agent needs that code too.
  • Going through MCP: the code for each API sits in an MCP server. A second AI app can use the same server.

MCP vs API, side by side

Question

API

MCP

Who is it for?

Any software

AI apps

Who picks the call?

A developer, when writing the code

Usually the model, while it works

How do you learn what's there?

Documentation, or an OpenAPI file if there is one

Ask the server: tools/list

What does a call look like?

Each API has its own design

The same message format for every server

Are the steps fixed?

Yes, by your code

Not usually, the model decides as it goes

Does it use the model's context?

Not when your code calls it

Yes: tool descriptions and results take up room

Strictly speaking, MCP is an API too, in the broad sense of an agreed way for programs to talk. When people say "MCP vs API", they mean MCP compared with calling a service's own web API directly.

Build the MCP server

This is the whole server, in JavaScript. Install the two packages with npm install @modelcontextprotocol/server@2.4.0 zod@4.6.7 and save it as server.mjs:

Text
import { McpServer } from "@modelcontextprotocol/server";import { serveStdio } from "@modelcontextprotocol/server/stdio";import { z } from "zod";function createServer() {  const server = new McpServer({ name: "orders", version: "1.0.0" });  server.registerTool(    "get_order",    {      description: "Look up one order by its number: status, carrier and delivery date.",      inputSchema: z.object({ id: z.number().int().positive().describe("Order number, such as 1042") }),    },    async ({ id }) => {      const res = await fetch(`http://127.0.0.1:3690/orders/${id}`);      return { content: [{ type: "text", text: await res.text() }], isError: !res.ok };    },  );  return server;}serveStdio(createServer);

And here is the API it calls. Save it as api.mjs and start it with node api.mjs:

Text
import { createServer } from "node:http";const orders = { 1042: { id: 1042, status: "shipped", carrier: "Llama Express", eta: "2026-12-08" } };createServer((req, res) => {  const id = req.url.match(/^\/orders\/(\d+)$/)?.[1];  const order = req.method === "GET" && orders[id];  res.writeHead(order ? 200 : 404, { "content-type": "application/json" });  res.end(JSON.stringify(order || { error: "order not found" }));}).listen(3690, "127.0.0.1");

To try it, add node /full/path/to/server.mjs as a local MCP server in an AI app that can start one, such as Claude Code or Visual Studio Code, and ask about order 1042. Two details matter:

  • The description is part of the interface. It's what the model reads when it chooses a tool, so a vague one gets the wrong tool picked.
  • Errors go back to the model. Ask for order 7 and the API's "order not found" comes back marked isError, so the model can correct itself or tell you.

Following an older tutorial? The July 2026 version of MCP removed the opening handshake and sessions. In the JavaScript package, a server started with server.connect(new StdioServerTransport()) still runs, but only serves apps that use the 2025 versions. serveStdio handles both.

When you need which

Call the API directly when your code already knows what to do: a checkout, a nightly report, a mobile app's screens. A model in the middle adds cost, delay and a chance of the wrong choice.

Use tool calling without MCP when you're building one AI app with a few tools of its own. Model providers let you describe functions in the request, and your code runs the ones the model asks for.

Add an MCP server when the same tools should work in several AI apps, or in apps other people build. You write the integration once, rather than once per app.

Before you connect one

  • Offer less than the API does. An assistant that answers order questions needs get_order, not delete_order.
  • Keep a person in the loop. The MCP specification says there should always be someone able to refuse a tool call.
  • Don't pass tokens through. An MCP server must not accept a token issued for another service and forward it to the API. It needs its own credentials for the API behind it.
  • Don't trust what comes back. Text returned by a tool, such as a customer's note on an order, can contain instructions aimed at the model. Treat it as data, and ask before doing anything that matters.
  • Watch the number of tools. With hundreds loaded up front, their descriptions can fill most of the model's context before it reads your question. Some apps search for tools and load only the ones they need.

Common questions

Does MCP replace REST APIs?

No. An MCP server commonly sits in front of a REST API and calls it. Your website, mobile app and partners keep using the API as they do now.

Do I need an API before I can build an MCP server?

No. A server can also read files, query a database or run a local program. If you do have an API, wrapping it is usually the quickest start.

Isn't that what OpenAPI is for?

Partly. An OpenAPI file describes a web API so that people and programs can understand it. It doesn't make the calls. MCP covers both: listing the tools, and running them in the same way for every server.

Is MCP only for Claude?

No. It's an open standard, and ChatGPT, Visual Studio Code and Cursor support it as well as Claude.

Keep going

For an agent that uses tools on a real problem, see the Strands harness worked example, which fixes a broken Kubernetes app. For the tokens that protect APIs and remote MCP servers, read OAuth 2.0 vs OpenID Connect.

More from the blog