No history yet

MCP Architecture

The MCP Architecture

Artificial intelligence often needs to interact with the outside world, whether that's reading files, accessing databases, or using online services. Historically, connecting an AI to these external tools required custom, one-off integrations for each connection. This process is brittle and doesn't scale. The Model Context Protocol (MCP) solves this by creating a universal standard for these interactions, much like USB-C replaced a tangled mess of proprietary chargers.

MCP (Model Context Protocol) is an open-source standard that defines how AI applications communicate with external systems through a unified interface.

MCP's architecture is built on a client-server model designed for clarity and modularity. It consists of three distinct components: the Host, the Client, and the Server. Understanding their roles is key to grasping how MCP enables complex, agentic AI workflows.

The Host is the primary, user-facing application. Think of an AI-powered code editor like Cursor or a chat interface like Claude Desktop. The host is responsible for managing the overall user session, handling permissions, and orchestrating which external services are needed. It contains one or more clients.

A Client is a lightweight component running inside the host. For every external service the host needs to talk to, it spins up a dedicated client. Each client maintains a one-to-one, stateful connection with a single server. It acts as a direct line of communication, passing messages back and forth.

A Server is an external program that exposes specific capabilities to the AI. A server might wrap a filesystem, a database, a set of APIs, or even a command-line tool. It listens for connections from clients and responds to their requests.

How They Communicate

The communication between a client and a server relies on , a simple and lightweight remote procedure call protocol. Using JSON makes the messages human-readable and platform-independent. This is a deliberate choice over more complex protocols to keep the system flexible and easy to implement.

When a client first connects to a server, they perform a handshake. During this initial exchange, the client asks the server what it can do. The server responds by announcing its capabilities. This process, called capability negotiation, is crucial. It means the host application doesn't need to have hard-coded knowledge of every server's functions. It can dynamically discover and adapt to the tools available at runtime.

This handshake turns a static connection into a dynamic partnership. The AI can ask, "What tools do you have?" instead of assuming what's available.

A key feature of MCP is that client-server connections are stateful. This stands in contrast to common web APIs (like REST), which are typically stateless. In a stateless interaction, every request must contain all the information needed to process it. The server forgets everything after sending its response.

In a stateful MCP session, the server maintains context throughout the connection. It remembers previous interactions with that specific client. This is vital for complex, multi-step tasks where the AI needs to perform a sequence of actions that build on each other, like reading a file, modifying its contents, and then saving it back.

The Building Blocks of Capability

An MCP server doesn't just offer a single function. It exposes its capabilities through three specific primitives: Tools, Resources, and Prompts. These primitives give the AI a structured way to understand and interact with the server.

PrimitiveDescriptionExample Use Case
ToolsExecutable functions the AI can invoke.A server could offer a run_python_script tool that takes a string of code and executes it.
ResourcesData sources the AI can read from.A server managing a project could expose the file tree and file contents as resources.
PromptsReusable templates to guide model interaction.A server could provide a system prompt or few-shot examples that instruct the AI on how to best use its tools.

By organizing capabilities into these three types, MCP creates a clear and predictable interface. It allows an AI agent not just to call a function, but to reason about the data it can access, the actions it can perform, and the best way to structure its requests. This modular architecture is the foundation for building powerful, interoperable, and truly agentic AI systems.