Architecting with Model Context Protocol
MCP Architecture Primitives
Clients, Servers, and the MCP Handshake
At its core, the Model Context Protocol (MCP) operates on a client-server architecture. It provides a standard, binary-independent way for an AI to communicate with its environment. In this model, the roles are distinct.
The Client is the AI agent or application. It acts as the orchestrator, making decisions about what it needs to accomplish a task. For example, an AI assistant running in your code editor acts as a client when it needs to read a file or run a command.
The Server is a program that provides access to the environment. It acts as a resource provider, exposing specific capabilities to the client. A single client can connect to multiple servers simultaneously, each offering a different set of functionalities, like accessing the local filesystem, querying a database, or interacting with a cloud API.
MCP follows a client-server architecture where an MCP host — an AI application like Claude Code or Claude Desktop — establishes connections to one or more MCP servers.
This separation allows for a modular and secure system. The AI agent doesn't need to know the low-level details of how to read a file or call a specific API. It just needs to know how to speak MCP. This entire conversation happens over a standardized communication layer using .
The protocol itself is transport-agnostic. For local processes, like an agent communicating with a tool running on the same machine, communication can happen over standard input/output (stdio). For networked scenarios, it can use HTTP with Server-Sent Events (SSE) for real-time updates. This flexibility allows MCP to adapt to different use cases seamlessly.
The Three Primitives
An MCP server doesn't just offer a random collection of functions. It exposes its capabilities through three specific, well-defined primitives. This structure helps the AI client understand what it can do and how to do it.
MCP defines three core primitives that servers can expose: Tools, Resources, and Prompts.
Resources are read-only data sources. They provide the AI with contextual information about the environment. This could be the content of a file, a list of running processes, or the results of a database query. The key is that accessing a resource doesn't change anything in the environment.
Tools are executable functions that allow the AI to perform actions and cause side effects. This is how an agent acts on the world. Examples include writing to a file, running a shell command, or sending an API request to book a flight.
Prompts are reusable templates that help structure interactions with the language model. They can be system prompts that set the overall behavior of the agent or few-shot examples that guide the model on how to perform a specific task correctly. Servers can provide these to help clients use their tools and resources more effectively.
| Primitive | Description | Example Use Case |
|---|---|---|
| Resource | Provides read-only data for context. | readFile("main.py") to see code. |
| Tool | An executable function that causes a side effect. | writeFile("main.py", "...") to change code. |
| Prompt | A reusable template for guiding the LLM. | A system prompt for acting as a pair programmer. |
Why a Unified Protocol?
Before MCP, developers building AI agents had to create custom, one-off integrations for every tool. An agent built to work in one code editor couldn't be easily moved to another, because the way it interacted with the file system and terminal was specific to that single environment. This created a fragmented ecosystem where agents were tightly coupled to their hosts.
MCP solves this by abstracting the environment. It creates a universal standard, much like HTTP did for the web or USB did for peripherals. This focus on a common interface leads to true . An AI agent designed to speak MCP can be dropped into any MCP-compliant host, whether it's Claude Desktop, a custom IDE, or a server-side application, and it will know how to interact with the world around it.
The protocol lifecycle is straightforward. When a client connects to a server, it first performs an initialization handshake. During this process, the server sends the client a manifest of all the resources, tools, and prompts it has available. From that point on, the client knows exactly what it can ask the server to do and can begin its work of orchestrating tasks.
In the Model Context Protocol (MCP) architecture, what is the primary role of the Server?
An AI agent needs to read the contents of a configuration file to understand the current project setup. According to the MCP, which primitive would it use for this read-only operation?
This client-server architecture, built on a simple communication layer and three core primitives, provides a powerful and flexible foundation for building portable, capable AI agents.