Skip to content

What is MCP? The Model Context Protocol in production

MCP, the Model Context Protocol, lets LLM apps use tools and data through one interface. What an MCP server is, how it works, and what to secure.

Published
Updated
Reading time
11 min read

In short

  • MCP, the Model Context Protocol, is an open standard for connecting LLM applications to tools and data. Messages are JSON-RPC 2.0.
  • A host application runs one client per server. An MCP server exposes tools, resources, and prompts, either locally over stdio or remotely over Streamable HTTP.
  • The 2026-07-28 revision made the protocol stateless. There is no handshake and no session, so a remote server can sit behind an ordinary load balancer.
  • Treat every tool description and tool result as untrusted input. Authorize per user, require approval for actions that write, and never pass a user's token through to another API.

MCP, the Model Context Protocol, is an open standard that defines how an LLM application connects to external tools and data. A tool is written once as an MCP server, and any application that speaks the protocol can use it.

Before MCP, each application wrote its own integration for each system it touched. Anthropic introduced the protocol in late 2024 to replace that with one interface. In December 2025 it donated MCP to the Agentic AI Foundation, a fund under the Linux Foundation, so no single vendor controls the specification.

How MCP is organized

MCP has three roles: a host, a client, and a server. The host is the application the user runs, such as an IDE, a chat app, or an agent runtime. Inside it, one client is created for each server, and each client keeps a one-to-one connection with that server.

HostIDE · CHAT APP · AGENT RUNTIMEModelMCP clientMCP clientMCP clientJSON-RPC 2.0Filesystem serverLOCAL · STDIODatabase serverLOCAL · STDIOSaaS API serverREMOTE · STREAMABLE HTTPEACH EXPOSES TOOLS · RESOURCES · PROMPTS
One host runs one client per server. Each client holds its own connection.

All messages are JSON-RPC 2.0. The application developer does not write those by hand. An SDK on each side handles the wire format.

What a server exposes

A server exposes three kinds of capability.

  • Tools are functions the model can call, such as running a query or creating a ticket. Each has a name, a description, and a JSON Schema for its input.
  • Resources are data the application can read, such as a file or a database row.
  • Prompts are reusable templates that a user chooses to run.

Tools carry most of the weight, because the model decides when to call them. The host sends the tool definitions to the model with the conversation, and the model replies with a call when it judges one is needed.

A tool definition, as returned by tools/list
{
  "name": "search_orders",
  "description": "Find orders by customer email. Read-only.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "email": { "type": "string" }
    },
    "required": ["email"]
  }
}

Read that description as part of your prompt, because it is. The model sees it on every request.

What is an MCP server

An MCP server is a program that wraps one system, such as a repository, a database, or a SaaS API, and offers it to any MCP host as tools, resources, and prompts. It runs either on the user's machine, started by the host, or as a remote HTTP service that many users share.

Most servers are thin wrappers over an existing API. The real work is choosing which operations to expose, describing them well enough that the model picks the right one, and checking every argument.

ServerRuns asWhat it exposesWhat limits it
Filesystem (reference)Local, stdioFile operationsAccess only to the directories you configure
Git (reference)Local, stdioRead, search, and change a repositoryThe repositories you point it at
Fetch (reference)Local, stdioWeb pages converted for the modelNothing: every page it returns is untrusted text
GitHub (official)Local or remoteRepos, issues, pull requests, Actions, and moreA read-only mode and a toolset allowlist

The MCP project keeps a few reference servers as examples. Production servers usually come from the vendor of the system, and GitHub's official server is a good model: it runs locally or remotely, groups its tools into toolsets, and has a --read-only flag that skips every write tool.

Build a minimal MCP server

A minimal MCP server is about a dozen lines with an official SDK. The SDK handles JSON-RPC, protocol versions, and the transport. You write ordinary functions, and the SDK builds each tool definition from the function's name, typed parameters, and docstring.

server.py
from mcp.server import MCPServer
 
mcp = MCPServer("orders")
 
ORDERS = {"ada@example.com": ["A-1001", "A-1007"]}
 
 
@mcp.tool()
def search_orders(email: str) -> list[str]:
    """Find orders by customer email. Read-only."""
    return ORDERS.get(email, [])
 
 
if __name__ == "__main__":
    mcp.run()  # stdio by default

This is the search_orders tool from the definition above. In the Python SDK, mcp.run() with no arguments starts a stdio server, and uv run mcp run server.py --transport streamable-http serves the same file over HTTP. uv run mcp dev server.py opens the MCP Inspector, where you can call each tool by hand before any model sees it.

How clients and servers talk

The specification defines two transports: stdio and Streamable HTTP.

With stdio, the client starts the server as a child process and exchanges messages over standard input and output. Use it for a tool that runs on the user's own machine with the user's own access, such as a filesystem or a local Git repository.

With Streamable HTTP, the server exposes a single HTTP endpoint. The client sends each message as a POST, and the server answers with JSON or with a stream of events for that request. Use it for anything a team shares.

An older transport from 2024, HTTP with a long-lived SSE connection, is deprecated. If a server's documentation still describes two endpoints, it predates the current design.

If an HTTP server runs on a laptop, it must validate the Origin header and should bind to 127.0.0.1, or a web page the user visits can reach it through DNS rebinding.

What the July 2026 revision changed

The revision dated 2026-07-28 made MCP stateless. Earlier revisions opened every connection with an initialize handshake and tracked a session afterwards. The current one removes both.

The changes that affect how you run a server:

  • Every request now carries its own protocol version and client capabilities.
  • Protocol-level sessions and the Mcp-Session-Id header are gone.
  • A new mandatory call, server/discover, tells a client what a server supports.
  • Servers no longer send requests to clients.
  • Sampling, roots, and logging are deprecated, and tasks moved out of the core into an extension.

The practical effect is that any instance of a server can answer any request. You can put MCP servers behind a normal load balancer and scale them like any other HTTP service, without sticky sessions.

If you built on a 2025 revision, expect a mixed fleet for a while. The specification includes a compatibility path for handshake-based clients, so check which revisions your SDK supports before you upgrade a server that other teams depend on.

MCP vs function calling and plain APIs

MCP does not replace function calling or APIs. Function calling is how a model asks for a tool inside one API request. An API is the system the tool talks to. MCP sits between them as a standard way for a host to discover tools on a server and call them, so one integration works in many hosts.

The layers stack: a host lists a server's tools, hands them to the model through function calling, and forwards each call back to the server. Tool calling covers that loop from the model's side.

Function callingMCP serverDirect API call
Where tools are definedIn your code, sent with each requestOn the server, discovered with tools/listNowhere. Your code calls the API
Who can reuse itThe application that defines itAny MCP hostAny code with credentials
Best fitOne app with a few tools it ownsThe same tools in several hostsFixed steps where the model does not choose

Write an MCP server when the same tools should work in several hosts or another team owns the system. Keep tools inline when one application owns a handful of them. Provider APIs now accept MCP directly too: OpenAI's Responses API takes a remote MCP server as a tool.

What to lock down before production

Four things need attention before an MCP server handles real work: authorization, trust in tool content, local servers, and the number of tools. MCP security is the full threat model, with each attack and the control that contains it.

Authorization

For HTTP servers, the specification builds on OAuth 2.1. The MCP server acts as a resource server and validates tokens that were issued for it specifically.

One rule matters more than the rest. A server must not accept a token meant for another service, and must not forward the client's token to a downstream API. The specification calls this token passthrough and forbids it. A server that needs to call another API gets its own credentials for that API.

Audience binding enforces it. Clients name the server a token is for with the RFC 8707 resource parameter, and the server checks that the audience is itself, so a token stolen from one server fails against the rest.

Authorize each user, not each server. A shared token lets every caller do everything it allows, and the logs cannot tell callers apart. The specification lets tools/list vary with the caller's authorization, so each user sees only the tools their scopes permit. Grant narrow scopes first; the security guide lists omnibus scopes such as full-access as a common mistake.

For stdio servers, the specification says to read credentials from the environment and not use the OAuth flow.

Untrusted tool content

A tool description is text that enters the model's prompt, and so is every tool result. A malicious or compromised server can use either one to give the model instructions. The 2026 OWASP Top 10 for LLM applications names MCP server output as a channel for indirect prompt injection.

Results are the larger exposure. A Fetch server returns whatever page the model asked for, and an issue tracker returns text anyone can write. Prompt injection explains why filtering that text is not enough.

The specification's answer has two parts. Clients must treat tool annotations as untrusted unless they come from a trusted server, and a human should be able to deny a tool call. Servers must also validate inputs, rate limit calls, and sanitize outputs.

Apply that as a policy. Allow read-only tools from servers you operate to run without a prompt. Require confirmation for anything that writes, sends, or deletes. The guardrails article explains why limiting actions works better than filtering text.

Local servers

A local server is code that runs with the user's privileges. The security guide's example is a one-click install whose startup command also posts the user's SSH key to a remote host, so clients must show the exact command and get approval before running it. Ship local servers over stdio, which only the launching host can reach.

Tool count

Every connected server adds its tool definitions to the prompt on every request. A few servers can put thousands of tokens of schema in front of the model before the user has typed anything.

That costs money, and it gives the model more chances to pick the wrong tool. It is the same failure described in the context rot article. Expose the tools a task needs and leave the rest disconnected. When the missing piece is procedure rather than access, a skill costs far less context than another server; see skills vs MCP. GitHub's server, for example, takes a --toolsets flag that allow-lists groups of tools.

Where an MCP gateway fits

An MCP gateway is a proxy between hosts and MCP servers. It gives you one place to authenticate callers, keep an allowlist of approved servers and tools, and log every tool call.

The case for it mirrors the case for an LLM gateway. You need one when several teams connect agents to shared systems and someone has to answer for what those agents can reach. A single developer running local stdio servers does not.

A gateway takes over four jobs a bare setup leaves to every host: one endpoint for every approved server, with tool names prefixed to avoid collisions; the right downstream credential for each user; a tool list filtered per caller; and one log of every call. The stateless revision makes this easier, because each request stands alone and names its method and tool in HTTP headers that a gateway can route on without parsing the body.

Bifrost, an open-source AI gateway by Maxim AI, is one example. As an MCP gateway it connects to servers over stdio, HTTP, or SSE, offers their tools to hosts such as Claude Desktop and Cursor through one endpoint, and filters which tools each virtual key can call. What an MCP gateway does compares the options and covers authentication and audit in depth.

The official MCP Registry does not fill that role. It is a public index of server metadata, it is still in preview, and it does not hold private servers. An allowlist of what your company has approved remains yours to keep.

Frequently asked questions

What is MCP in simple terms?

MCP is a shared plug format for AI tools. A system such as GitHub or a database is wrapped in an MCP server once, and every application that supports MCP, from an IDE to a custom agent, can use it without a new integration. The model picks a tool, and the host makes the call.

What is the difference between MCP and an API?

An API is how software talks to a system. MCP is how an AI application discovers and calls tools, and most MCP servers call an API underneath. An MCP server describes its tools so a model can choose among them at runtime; an API expects the caller to already know which endpoint to use.

Is MCP the same as function calling?

No. Function calling is a model feature: the model returns a structured request to run a tool defined in the API call. MCP is a protocol between an application and a tool server. They work together: the host fetches tools from MCP servers, passes them to the model through function calling, and routes each call back.

Which applications support MCP?

Desktop hosts such as Claude Desktop, Cursor, and VS Code connect to MCP servers listed in a JSON config file. OpenAI's Responses API accepts a remote MCP server as a tool and, by default, asks for approval before sharing data with it. Custom agents can use the official SDKs.

Is MCP secure?

MCP defines the controls but cannot enforce them. The real risks sit around the protocol: tool results that carry injected instructions, local servers that run arbitrary commands, and tokens with broad scopes. Per-user authorization, approval for writes, and a short list of approved servers address most of them.

Sources

  1. 01Specification, current revisionModel Context Protocol
  2. 02VersioningModel Context Protocol
  3. 03Changelog, revision 2026-07-28Model Context Protocol
  4. 04Streamable HTTPModel Context Protocol
  5. 05ToolsModel Context Protocol
  6. 06AuthorizationModel Context Protocol
  7. 07Security best practicesModel Context Protocol
  8. 08About the MCP RegistryModel Context Protocol
  9. 09Reference serversGitHub
  10. 10MCP Python SDKGitHub
  11. 11GitHub MCP ServerGitHub
  12. 12Connectors and MCP serversOpenAI API docs
  13. 13Donating the Model Context Protocol and establishing the Agentic AI FoundationAnthropic
  14. 14OWASP Top 10 for LLM Applications 2026OWASP GenAI Security Project
  15. 15MCP gatewayBifrost docs