No history yet

MCP Architecture Fundamentals

The Host, Client, and Server Triad

At its heart, the Model Context Protocol (MCP) organizes communication between three distinct roles: the Host, the Client, and the Server. This isn't just a simple client-server setup; it's a structured relationship designed for complex, ongoing conversations between an AI and its tools.

Think of it like a specialist consultation. You go to a general practitioner's office (the Host), which is your primary point of contact. The GP (the Client) understands your needs and knows which specialist (the Server) to call. The Client handles the communication, translating your needs into a technical request for the Server and bringing the response back to you within the context of the Host application.

Let's break down each role:

  • The Host: This is the user-facing AI application. It could be a coding assistant inside an IDE, a chatbot interface, or an automation platform. The Host's main job is to manage the user experience and decide when it needs external information or capabilities.

  • The Client: The Client is a component that lives inside the Host. It acts as a dedicated messenger, responsible for discovering, connecting to, and communicating with MCP Servers. It speaks the language of MCP.

  • The Server: This is a program that provides access to a specific tool, dataset, or capability. One server might wrap a database, another might provide access to a file system, and a third could connect to a company's internal API. Each Server advertises what it can do.

The Communication Layer

Unlike many web APIs that use REST, MCP uses for communication. This choice is deliberate. JSON-RPC is a lightweight remote procedure call protocol. In simple terms, it lets the Client directly ask the Server to run a specific function with certain parameters and get a result back.

This is more efficient for the kind of stateful, back-and-forth conversations that AI agents need. Instead of the Client just GETting or POSTing data to a URL, it can make specific requests like workspace.readFile or database.queryUsers. This direct-style calling makes integrations feel less like fetching web pages and more like using a local library.

// Example Request from Client to Server
{
  "jsonrpc": "2.0",
  "method": "workspace/getDirectory",
  "params": {
    "path": "/src/components"
  },
  "id": 1
}

// Example Response from Server to Client
{
  "jsonrpc": "2.0",
  "result": {
    "files": ["Button.js", "Card.js"]
  },
  "id": 1
}

Connection and Negotiation

The lifecycle of an MCP connection follows a clear, structured path that ensures both sides know what to expect.

  1. Discovery: The Host first needs to find available MCP Servers. This might happen through a local registry, network discovery, or user configuration. The goal is to get a list of servers the Client can potentially connect to.

  2. Connection: The Client establishes a connection with a Server. This creates a persistent communication channel, usually over a WebSocket or a standard I/O stream, allowing for bi-directional messaging.

  3. Initialization and : This is the crucial handshake. Once connected, the Client and Server exchange initialize messages. In this step, the Server tells the Client exactly what it can do, for example, {"canReadFiles": true, "canWriteFiles": false}. The Client acknowledges these capabilities and may provide its own information. This negotiation ensures that the Client never asks a Server to do something it doesn't support, preventing errors and making the system robust.

  4. Interaction: With capabilities established, the Client can now send JSON-RPC requests to the Server to perform actions or retrieve data. The Server processes these requests and sends back responses. This is where the real work happens.

  5. Termination: When the session is over, the Client sends a shutdown request, followed by an exit notification, to gracefully close the connection.

This structured lifecycle is what allows MCP to be a reliable and open standard. By clearly defining the rules of engagement, any Host can work with any Server, replacing a fragmented ecosystem of custom integrations with a unified, plug-and-play architecture.

Quiz Questions 1/5

In the Model Context Protocol (MCP), which component is the user-facing AI application, such as a chatbot interface or a coding assistant?

Quiz Questions 2/5

What is the primary purpose of the 'Capability Negotiation' step in the MCP connection lifecycle?

Understanding this architecture is the first step toward building powerful, context-aware AI applications.