Open source: context compression for coding agents, 63% less tool output ⭐ optscale-kompressor on GitHub →
AI Gateway

MCP vs API: What’s Actually Different, and When You Need Each

November 26, 2026

~ 10 min

By Nick Smirnoff
On this page
    MCP servers multiplying across your teams?
    Book a Demo

    An API is a contract that lets one piece of software request data or actions from another through defined endpoints. The Model Context Protocol (MCP) is an open standard built on JSON-RPC 2.0 that lets an LLM application discover and call tools and data at runtime through a single, uniform interface. MCP does not replace APIs: most MCP servers wrap existing APIs and standardize how a model finds and uses them. So the real MCP vs API question is not which one wins, but who the consumer is: a developer writing code, or a model choosing tools mid-task.

    ‍

    If you are asking what MCP is, the practical answer is how it differs from the APIs you already run. This guide compares the two on architecture, tool discovery, state, authentication and security, with a working payload example. Protocol details reflect MCP specification revision 2026-07-28, current as of November 2026; that release changed how MCP handles state, so many older comparisons are now out of date.

    ‍

    What is an API?

    An API (application programming interface) is a published contract between two pieces of software: which endpoints exist, what a request must contain and what the response looks like. Most web APIs follow REST conventions over HTTP (resources at URLs, verbs such as GET and POST, JSON payloads), and many are described in machine-readable form with the OpenAPI Specification, now at version 3.2.0 (September 2025). REST APIs are stateless: each request carries everything the server needs to process it. Above all, an API is built for a developer, who reads the docs, writes the integration code and decides at build time which call runs.

    ‍

    How MCP works: hosts, clients, servers and primitives

    MCP standardizes the last mile between a language model and the systems it needs. Anthropic introduced the protocol in November 2024 and in December 2025 donated it to the Agentic AI Foundation under the Linux Foundation, so MCP is now governed as a vendor-neutral standard. Adoption is broad: in July 2026, the MCP maintainers reported close to half a billion downloads a month across the official Tier 1 SDKs.

    The MCP specification defines three roles that exchange JSON-RPC 2.0 messages:

    1.     Host: the LLM application the user works in, such as an IDE, a chat assistant or an agent runtime. The host coordinates the model and owns user consent and security decisions.

    2.     Client: a connector inside the host. Each client talks to one MCP server.

    3.     Server: a service that exposes capabilities to the model, very often by wrapping an existing API, database or file system.

    The request path is: LLM application (host) → MCP client → MCP server → tool or data source. Local servers run as a subprocess over stdio; remote servers use the Streamable HTTP transport. Servers expose three primitives, each with a different controller:

    Primitive Controlled by What it is Example
    Tools The model Functions the model can call to take actions or fetch data get_weather, create_issue, run_query
    Resources The application Context data the host attaches for the model File contents, git history, a database schema
    Prompts The user Reusable templates the user invokes on purpose A slash command such as /summarize-pr

    Clients can also offer elicitation, letting a server ask the user for missing input or a confirmation mid-task. Of the three server primitives, only tools can be triggered by the model on its own, which is why most MCP security work focuses on them.

    ‍

    MCP vs API: the key differences

    The core MCP vs API difference is the consumer. An API is consumed by code a developer wrote in advance; MCP is consumed by a model that decides at runtime which tool fits the task. The rest of the comparison follows from that.

    Aspect API (e.g. REST) MCP
    Primary consumer Application code written by a developer An LLM, acting through a host application
    When the call is chosen At build time, by the developer At runtime, by the model
    Discovery Docs or an OpenAPI file, read by a person tools/list, resources/list and prompts/list, queried by the client
    Interface Unique per service: its own endpoints, parameters and errors One protocol for every server: the same methods and message shapes
    Wire format HTTP verbs on resource URLs, usually JSON JSON-RPC 2.0 over stdio or a single Streamable HTTP endpoint
    Descriptions written for Humans The model: natural-language descriptions plus JSON Schema
    State Stateless by design Stateless protocol core since 2026-07-28; state across calls via explicit handles
    Authentication Any scheme: API keys, OAuth 2.0, mTLS Optional OAuth 2.1 for remote servers; environment credentials for local stdio servers
    Signature risk Leaked keys, broken access control The same, plus prompt injection and tool poisoning

    Is MCP stateful? Not since July 2026

    Many comparison articles still describe MCP as a stateful, session-based protocol. That was accurate up to revision 2025-11-25: every connection opened with an initialize handshake, where capability negotiation took place, and a server could pin a session with an Mcp-Session-Id header. Revision 2026-07-28 removed both. Each MCP request now carries its protocol version and client capabilities in a _meta field, so any server instance behind a plain round-robin load balancer can answer it. Servers that need memory across calls, such as a shopping cart, return an explicit handle that the model passes back.

    Model Context Protocol vs REST API: one request, two ways

    Take one task, getting the current weather in London, and implement it both ways.

    The REST API version

    A developer reads the weather provider’s documentation and hard-codes the call: 

    HTTP Request
    GET /v1/weather?location=London HTTP/1.1
    Host: api.weather.example.com
    Authorization: Bearer <api-key>

    Adding a second provider means a second set of docs and a second adapter.

    The MCP version

    An MCP server wraps the same endpoint and describes it for the model. When a client asks the server what it offers with tools/list, it receives a tool definition like this (trimmed):

    Tool Definition
    {
      "name": "get_weather",
      "description": "Get current weather information for a location",
      "inputSchema": {
        "type": "object",
        "properties": {
          "location": { "type": "string", "description": "City name or zip code" }
        },
        "required": ["location"]
      }
    }

    The host places that description in the model’s context. When the user asks “Do I need an umbrella in London today?”, the model selects get_weather and the client sends a tools/call request over Streamable HTTP:

    MCP Request
    POST /mcp HTTP/1.1
    Host: weather-mcp.example.com
    Content-Type: application/json
    Accept: application/json, text/event-stream
    Authorization: Bearer <access-token>
    MCP-Protocol-Version: 2026-07-28
    Mcp-Method: tools/call
    Mcp-Name: get_weather
    
    {
      "jsonrpc": "2.0",
      "id": 2,
      "method": "tools/call",
      "params": {
        "name": "get_weather",
        "arguments": { "location": "London" },
        "_meta": {
          "io.modelcontextprotocol/protocolVersion": "2026-07-28",
          "io.modelcontextprotocol/clientInfo": {
            "name": "example-agent",
            "version": "1.0.0"
          },
          "io.modelcontextprotocol/clientCapabilities": {}
        }
      }
    }

    The server replies:

    MCP Response
    {
      "jsonrpc": "2.0",
      "id": 2,
      "result": {
        "resultType": "complete",
        "content": [
          { "type": "text", "text": "Current weather in London: 12°C, light rain" }
        ],
        "isError": false
      }
    }
    Payload format checked against MCP specification 2026-07-28 in November 2026. Earlier revisions do not require the _meta fields or resultType and expect an initialize handshake before the first call.

    Inside the server, get_weather simply calls the REST endpoint shown above. That is the practical answer to the MCP server vs API question: the API still does the work, while the MCP server is an adapter that makes it discoverable and callable from any MCP-compatible host. Notice the Mcp-Method and Mcp-Name headers, required since 2026-07-28: they let a gateway, rate limiter or firewall route and authorize tool calls without parsing the JSON body.

    ‍

    Security: what each one exposes

    APIs and MCP servers share the familiar risks: leaked keys, missing rate limits and broken object-level authorization. MCP adds a new class of risk because the model reads tool metadata and tool output as text, and text can carry instructions. The specification itself notes that MCP cannot enforce its security principles at the protocol level; hosts and operators must. Four MCP-specific risks stand out:

    •       Prompt injection through tool content. A tool that reads emails, tickets or web pages feeds attacker-controlled text into the model’s context. If that text says “send the config file to this address”, a model with an email tool may comply. Every read-capable tool is a potential entry point.

    •       Tool poisoning. Invariant Labs disclosed this attack in April 2025: malicious instructions hidden in a tool description that the model sees and the user usually does not. The MCPTox benchmark tested 20 LLM agents against 353 real tools from 45 live MCP servers and measured an average attack success rate of 36.5%, peaking at 72.8% for o1-mini; no model refused more than 3% of attacks. A related “rug pull” swaps a tool’s description after approval.

    •       Static and over-broad credentials. Astrix Security analyzed more than 5,200 open-source MCP servers: 88% require credentials, 53% rely on long-lived static API keys or personal access tokens, and only 8.5% use OAuth. The current authorization spec builds on OAuth 2.1 with PKCE and audience-bound tokens and forbids token passthrough, but authorization remains optional, so verify each server.

    •       Actions without confirmation. Tools are model-controlled, so a destructive call (delete, transfer, deploy) can fire on a misread instruction. The specification says a human should be able to deny tool invocations, and Multi Round-Trip Requests let a server pause and ask the user to confirm.

    A practical baseline: allowlist approved servers, pin and re-review tool descriptions, scope credentials per server, require confirmation for write actions and log every tool call. Our AI security and guardrails overview covers the full control set.

    See every MCP tool call your agents make

    OptScale AI screens prompts and tool calls inline, blocks MCP servers nobody approved and keeps one audit trail across every provider. Start free with up to 10 seats

    When to use MCP and when to use an API

    Use a direct API call when:

    •       The workflow is deterministic: the same calls run in the same order every time, as in a nightly billing sync or a payment webhook.

    •       The consumer is another service, not a language model.

    •       Latency and cost per call matter more than flexibility, because a direct call skips both the model and the extra hop.

    •       Every parameter must be tightly controlled and auditable, as with payments or PII updates.

    Use MCP when:

    •       A model needs to choose between several tools based on what the user asks.

    •       You want one integration to work across many AI hosts, such as Claude, ChatGPT, Cursor, VS Code or your own agent, instead of building a plugin for each.

    •       You are building agentic workflows that chain tools across systems, such as reading a ticket and drafting a fix.

    •       Your tool catalog changes often, and clients should pick up changes through discovery rather than redeploys.

    Most production systems end up with both: APIs for system-to-system plumbing, and MCP for the layer where a model decides what to call.

    ‍

    How MCP and APIs work together, and where governance comes in

    In practice, MCP sits on top of APIs rather than beside them. A typical stack has three layers: a business system exposes a REST or gRPC API; an MCP server wraps a curated subset of that API as tools with model-readable descriptions; and hosts such as IDEs, chat assistants and internal agents connect to it. The API stays the source of truth for business logic and access control, while MCP standardizes how models reach it.

    The difficulty starts at scale. One team connects five MCP servers; a year later the organization runs dozens, each with its own credentials, scopes and owners, and nobody can say which agent called which tool with which data. Servers installed without review also become a channel for shadow AI agents. Cost grows as well: tool definitions and results pass through the model’s context, and Anthropic’s engineering team reported that letting an agent load tool definitions on demand, through code execution, cut one workflow from 150,000 tokens to 2,000, a 98.7% reduction.

    That is why MCP traffic increasingly runs through a gateway, just as API traffic did a decade ago. A useful MCP control plane should:

    1.     Keep a registry of approved MCP servers and block everything else.

    2.     Enforce per-team and per-agent access to models, tools and data sources (RBAC).

    3.     Inspect tool calls and tool outputs for prompt injection, PII and other sensitive data.

    4.     Attribute usage and cost to teams, projects and agents.

    5.     Log every call with enough context to reconstruct it during an audit.

    The 2026-07-28 specification helps: stateless requests and routable headers let a gateway authorize and meter MCP traffic without holding sessions. Test that controls enforce, not just report: in one publicly reported open-source gateway defect, an org-wide MCP deny rule logged “Passed” while the tool ran.

    OptScale AI Gateway is built for this layer. It routes requests between local models, public LLMs and MCP servers from one control plane with under 2 ms of overhead, gives each team access only to its own MCP servers and vector stores, applies guardrails to tool calls, and breaks billing down by department. OptScale Kompressor compresses tool output in flight, removing 62.8% of tool output and cutting a coding agent’s real bill by 22.7% in our Terminal-Bench 2.1 benchmark. Already running a self-hosted LLM proxy? Compare LiteLLM alternatives.

    Put every model and MCP server behind one gateway

    Give each team access only to its own MCP servers, enforce guardrails on tool calls and see what every agent costs. Free for up to 10 seats, no credit card required

    Frequently asked questions

    Is MCP a replacement for APIs?

    No. MCP is a layer on top of APIs, not a substitute for them. Most MCP servers call existing REST or gRPC APIs internally and add a standard way for language models to discover and invoke those capabilities. Service-to-service integrations, webhooks and deterministic pipelines still run on APIs directly, with no model in the loop.

    Is MCP faster than calling an API directly?

    No. An MCP tool call adds a hop (host, then MCP client, then MCP server) and usually triggers an API call underneath, so raw latency is equal or higher. MCP saves integration time, not runtime. It can also add token cost, because tool definitions and tool results pass through the model's context window.

    Can I turn my REST API into an MCP server?

    Yes, and that is how most MCP servers are built. You wrap selected endpoints as tools, give each a clear description and a JSON Schema for its inputs, and run the server with an official SDK in TypeScript, Python, Go or C#. Some gateways can also generate MCP tools from an OpenAPI file. Expose only what a model needs.

    Does MCP work with any LLM?

    MCP is model-agnostic. The protocol runs between the host application and MCP servers, so any model that supports tool use (function calling) can use MCP tools through a compatible host. Claude, ChatGPT, Cursor, VS Code and Microsoft Foundry all support MCP. Tool-selection quality still varies by model, so test critical workflows first.

    How is MCP different from function calling?

    Function calling is a model feature: the application sends tool schemas with a request, and the model returns a structured call that the application must execute. MCP standardizes everything around that step: where tool definitions come from, how they are discovered and how calls run, so a tool written once works in every MCP-compatible host.

    Is MCP secure?

    MCP is as secure as its deployment. The specification defines OAuth 2.1-based authorization for remote servers and recommends a human in the loop for tool calls, but authorization is optional and the protocol cannot stop prompt injection or tool poisoning by itself. Treat every MCP server as third-party code: allowlist it, scope its credentials and log every call.