How Model Context Protocols Work: The Universal Adapter Behind Modern AI Agents

An in-depth look at how the Model Context Protocol (MCP) connects AI models to external tools and data, covering its client-server architecture, core primitives, and real-world applications.

How Model Context Protocols Work: The Universal Adapter Behind Modern AI Agents
Audio Article

For years, building an AI assistant that could actually do things in the real world meant writing a mountain of custom glue code. Large language models were smart, but they were trapped behind glass—frozen at the time of their training and isolated from your local files, company databases, and everyday software. If you wanted an AI coding assistant to read a database, you wrote a custom integration. If you wanted a second AI app to read that same database, you wrote it all over again. In software engineering, this is known as the M-times-N problem: M AI applications multiplied by N external tools equals a sprawling web of brittle, one-off connectors.

That changed with the rise of the Model Context Protocol, or MCP. Introduced by Anthropic in November 2024 and later donated to the Linux Foundation's Agentic AI Foundation in late 2025 alongside co-founders OpenAI and Block, MCP has become the open standard for connecting AI systems to external data and tools. Major platforms including Claude, ChatGPT, Google Gemini, Microsoft Copilot, and Cursor all support it, backed by more than thirteen thousand public servers. The simplest way to picture MCP is as a USB-C port for artificial intelligence. Instead of every device needing its own proprietary charger, one standardized interface lets any compliant AI application plug into any compliant data source or tool.

To understand how MCP actually works under the hood, it helps to trace the three main participants in its architecture: the Host, the Client, and the Server.

The MCP Host is the AI application you interact with—for example, Claude Desktop, Visual Studio Code, or an internal enterprise chatbot. The host houses the language model, manages the conversation, and enforces security policies and user permissions. Whenever the host needs to connect to an external system, it spins up an MCP Client. There is a strict one-to-one relationship here: if an AI app connects to Slack, GitHub, and a Postgres database at the same time, the host creates three separate MCP clients, each maintaining an isolated, stateful session with its corresponding server.

On the other end of the line sits the MCP Server. An MCP server is a lightweight program that wraps around a specific capability—like your computer's filesystem, a Google Cloud BigQuery warehouse, or a Jira board—and translates its native commands into the standardized MCP language.

How do the client and server actually talk to each other? Everything runs on JSON-RPC 2.0 messages sent over one of two official transport layers. For tools running locally on your own machine, MCP uses standard input and output, known as stdio. The host simply launches the server as a local subprocess and exchanges text-based messages directly. For tools hosted in the cloud or across a corporate network, MCP uses Streamable HTTP. In this setup, the server exposes a single HTTP endpoint that handles standard POST requests, supports OAuth 2.0 and bearer-token authentication, and can stream real-time updates back to the client using Server-Sent Events.

Once connected, the magic of MCP comes down to four core primitives that servers and clients exchange: Tools, Resources, Prompts, and Sampling.

First are Tools, which are model-controlled functions. When a client connects to a server, it doesn't guess what the server can do; it sends a discovery request called tools/list. The server replies with a structured menu of available actions—such as creating a support ticket or running a SQL query—complete with descriptions and strict input schemas. When you ask the AI to perform a task, the language model reads that menu, selects the right tool, and fills in the parameters. The host checks whether you have granted permission, sends a tools/call message through the client, and feeds the server's structured result back to the model.

Second are Resources, which are application-controlled data sources. Think of resources as read-only context: log files, database schemas, configuration files, or company policy documents. Instead of cramming an entire database into a prompt, the host can list available resources and fetch only the exact record the model needs using a resources/read call.

Third are Prompts, which are user-controlled templates. A server can expose predefined prompt workflows—like a standardized template for reviewing a pull request or summarizing a quarterly sales report—so users get consistent, domain-specific behavior without having to engineer complex instructions from scratch.

Fourth is Sampling, one of MCP's more subtle capabilities. Normally, the host calls the server. With sampling, the flow flips: an MCP server can send a request back up to the client asking the host's language model to generate a completion. This lets a server perform intelligent, multi-step reasoning on its own without needing its own AI API keys, while still keeping a human in the loop to review and approve the prompt before it runs.

Seeing these pieces come together in real-world AI systems makes the value of MCP clear.

Consider a software engineering workflow inside an AI-powered editor like Cursor or Claude Code. Suppose a developer asks the assistant to investigate a failing test, check recent code changes, and file a bug report. The host coordinates two MCP servers simultaneously: a local Git server running over stdio, and a remote GitHub server running over Streamable HTTP. The model discovers a git_log tool and file-reading resources on the local machine to trace the bug to a recent commit. Then, using the create_issue tool discovered from the GitHub server, it drafts and files a detailed issue with the exact stack trace—all without the editor having any hardcoded GitHub logic built into it.

Or take an enterprise IT help desk. Imagine an employee messaging an AI agent inside Slack because they lost their company laptop. Behind the scenes, the agent acts as an MCP host connected to an internal knowledge base and an IT service management platform like ServiceNow or Jira. First, it reads the company's lost-device policy exposed as an MCP Resource. Next, it asks the employee a couple of clarifying questions, and finally invokes a create_ticket tool via the ITSM server to log the incident with the proper priority and user details. Because the connection uses enterprise OAuth and scoped permissions, the agent only sees and touches what that specific employee is authorized to access.

The same pattern powers data analytics and multi-agent systems. An analytics assistant connected to a BigQuery MCP server can inspect table schemas as resources and execute read-only SQL queries as tools, returning live revenue figures rather than hallucinated estimates. In multi-agent setups, a planning agent can discover cloud-monitoring and cost-tracking tools via MCP, then hand off execution to a specialized deployment agent that discovers infrastructure tools over the exact same protocol.

Of course, standardizing AI tool access introduces new engineering trade-offs. Connecting dozens of MCP servers at once can flood a model's context window with hundreds of tool schemas, driving up token costs and slowing down responses. More importantly, security experts emphasize that MCP's biggest risk isn't the protocol itself—it is permission governance. Giving an autonomous model access to production databases or third-party servers requires strict least-privilege controls, human-in-the-loop approvals for sensitive actions, and careful defense against prompt injection hidden inside external data.

Even with those challenges, MCP has fundamentally reshaped how AI software is built. By separating the intelligence of the language model from the plumbing of external integrations, it turns fragile, custom-coded demos into modular systems where any model can reliably discover, read from, and act upon the tools we use every day.

Backgrounder Notes

To help readers navigate the technical, architectural, and security concepts referenced in the article, here is a structured reference guide of key terms and backgrounders.

AI & Model Concepts

  • Large Language Models (LLMs) & Training Cutoffs: LLMs are deep-learning AI systems trained on massive text datasets to understand and generate human-like language. Because their internal knowledge becomes static once training finishes—known as a "training cutoff"—they cannot natively access real-time information or private data without external integrations.
  • AI Hallucination: An AI hallucination occurs when a language model generates confident-sounding information that is factually incorrect, fabricated, or ungrounded in reality. Grounding models in live data sources helps prevent hallucinations by allowing the AI to retrieve verified facts rather than guessing.
  • Context Window & Tokens: A context window is the maximum amount of text—measured in "tokens" (roughly equivalent to words or word fragments)—that an AI model can hold in working memory during a single interaction. Because AI providers typically charge per token, loading too many tool definitions into the context window increases both financial cost and response latency.
  • Multi-Agent Systems: A multi-agent system consists of multiple specialized AI agents—autonomous programs capable of planning and taking actions—that collaborate to solve complex tasks. Dividing responsibilities (such as planning versus deployment) allows each agent to operate within a narrower domain using dedicated tools.

Protocols, Standards & Technical Architecture

  • The Linux Foundation: The Linux Foundation is a major non-profit technology consortium that hosts and supports open-source software projects. Donating a standard like MCP to it ensures vendor-neutral governance, meaning no single company can unilaterally control or lock down the protocol.
  • JSON-RPC 2.0: JSON-RPC 2.0 is a lightweight remote procedure call protocol that uses JSON (JavaScript Object Notation) to format messages between a client and a server. It allows one program to request that another program execute a specific function and return a structured result, regardless of the programming languages each uses.
  • Standard Input and Output (stdio): In computing, stdio refers to the standard text communication channels—input (stdin) and output (stdout)—built into operating systems for programs to read and write data. Using stdio allows a host application to communicate directly with a local background process without needing to configure network ports or web servers.
  • Server-Sent Events (SSE): SSE is a web technology that enables a server to push real-time updates to a client over a single, long-lived HTTP connection. Unlike traditional web requests where the client must repeatedly ask for updates, SSE lets the server stream data continuously as soon as it becomes available.
  • IT Service Management (ITSM): ITSM refers to the practices and software platforms (such as ServiceNow or Jira Service Management) that organizations use to design, deliver, and support IT services for employees. It standardizes internal workflows like incident reporting, hardware requests, and technical troubleshooting.

Security & Governance

  • OAuth 2.0 & Bearer Tokens: OAuth 2.0 is an industry-standard authorization framework that lets an application access a user's data on another service without ever seeing their password. It works by issuing "bearer tokens"—cryptographic strings that act like temporary, scoped digital keys proving the holder has permission to perform specific actions.
  • Principle of Least Privilege: Least privilege is a foundational cybersecurity principle dictating that a user, program, or AI agent should only be granted the minimum level of access and permissions necessary to perform its specific task. This limits the potential damage if the system makes an error or is compromised.
  • Prompt Injection: Prompt injection is a security vulnerability in which malicious instructions are hidden inside external data—such as a webpage, email, or database record—to hijack an AI model's behavior. If an AI reads poisoned data, it may be tricked into ignoring its original instructions and executing unauthorized tool calls.
  • Human-in-the-Loop (HITL): Human-in-the-loop is a system design approach that requires human review and approval before an automated system or AI agent executes critical or sensitive actions. It acts as an essential safeguard against unintended consequences, errors, or security breaches.
Link copied to clipboard!