Skip to content

MCP Architecture

  • Intermediate · Module 05
  • Lesson 2 of 5 · then sources and quiz

Step 1 of 4Knowledge

MCP follows a clear layered architecture. Each layer has a well-defined responsibility. Once you understand this architecture, you can debug, optimize, and build MCP integrations yourself.

Overview: Host -> Client -> Transport -> Server

+------------------------------------------+
|  HOST (e.g., Claude Desktop, Cursor)     |
|                                          |
|  +------------------------------------+  |
|  |  CLIENT (MCP Client Library)       |  |
|  |                                    |  |
|  |  +------------------------------+  |  |
|  |  |  TRANSPORT (stdio / HTTP)    |  |  |
|  |  +------------------------------+  |  |
|  +------------------------------------+  |
+------------------------------------------+
              |  JSON-RPC 2.0  |
              v                v
+------------------------------------------+
|  SERVER (e.g., GitHub MCP, Jira MCP)     |
|                                          |
|  - Tools     (execute functions)         |
|  - Resources (provide data)              |
|  - Prompts   (offer templates)           |
+------------------------------------------+

Layer 1: Host

The Host is the application you're working in -- Claude Desktop, Cursor, VS Code, or ChatGPT. The Host is responsible for:

  • User interface -- Displays results and accepts input
  • Security -- Decides which MCP servers are allowed to connect
  • Lifecycle management -- Starts and stops MCP clients

A Host can manage multiple clients simultaneously -- for example, one for GitHub and one for Jira.

Layer 2: Client

The Client is the bridge between Host and Server. It:

  • Maintains a 1:1 connection to exactly one server
  • Manages capability negotiation -- which features the server offers
  • Handles message routing between Host and Server
Note
1:1 Relationship

Each client connects to exactly one server. If the Host wants to use three MCP servers, it creates three separate clients.

Layer 3: Transport

The Transport determines how messages are physically transmitted. MCP supports two transport mechanisms:

TransportDescriptionUse Case
stdioCommunication via standard input/outputLocal servers, CLI tools
SSE (Server-Sent Events)HTTP-based, unidirectional stream + POSTRemote servers, cloud services (deprecated -- being replaced by Streamable HTTP)
Streamable HTTPBidirectional over a single HTTP endpointRemote servers, cloud services (recommended)

stdio is the most common transport for local development. The Host starts the server as a child process and communicates via stdin/stdout.

SSE was used for remote servers but is now deprecated. The recommended successor is Streamable HTTP, which enables bidirectional communication over a single HTTP endpoint.

Layer 4: Server

The Server provides the actual capabilities. It exposes:

  • Tools -- Functions that the LLM can call (e.g., "create a Jira ticket")
  • Resources -- Data that the LLM can read (e.g., "current sprint status")
  • Prompts -- Predefined prompt templates (e.g., "code review for PR #123")

More on these three primitives in the next section.

Step 2 of 4Understand

Architecture · The layers of MCP
Tap a layer to see details

The Protocol: JSON-RPC 2.0

MCP uses JSON-RPC 2.0 as its message format. It's a lightweight remote procedure call protocol that is well suited for communication between AI and external services.

Message Types

There are three types of JSON-RPC messages:

1. Request -- The client asks the server for something:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "create_issue",
    "arguments": {
      "title": "Login bug",
      "priority": "high"
    }
  }
}

2. Response -- The server replies:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Issue PROJ-456 created"
      }
    ]
  }
}

3. Notification -- A one-way message with no response:

{
  "jsonrpc": "2.0",
  "method": "notifications/progress",
  "params": {
    "progressToken": "abc",
    "progress": 50,
    "total": 100
  }
}
Tip
Why JSON-RPC?

JSON-RPC is simple, language-agnostic, and battle-tested. It has been used in many protocols for years (e.g., Ethereum, Language Server Protocol). MCP builds on this proven foundation.

The Connection Handshake

When a Host connects to an MCP server, the following process takes place:

  1. Initialize -- Client sends an initialize request with its capabilities
  2. Server responds -- Server reports its capabilities (which tools, resources, and prompts it offers)
  3. Initialized -- Client confirms with notifications/initialized
  4. Operation -- Messages flow in both directions
Client                          Server
  |                               |
  |-- initialize ----------------->|
  |                               |
  |<-- initialize (response) -----|
  |                               |
  |-- notifications/initialized -->|
  |                               |
  |== Connection active ===========|
  |                               |
  |-- tools/list ----------------->|
  |<-- tools/list (response) -----|
  |                               |
  |-- tools/call ----------------->|
  |<-- tools/call (response) -----|
Exercise · Fill in the gaps
Complete the MCP server configuration for Claude Desktop:
{ "mcpServers": { "github": { "": "npx",
"": ["-y", "@modelcontextprotocol/server-github"],
"": { "GITHUB_TOKEN": "ghp_xxxx" } } } }

Step 3 of 4Apply

Question · Self-check
A Host wants to use three different MCP servers (GitHub, Jira, Slack). How many MCP clients are needed?
Question · Self-check
What message format does MCP use for communication?

Step 4 of 4Reflect

The MCP architecture follows the principle of simplicity: Host, Client, Transport, Server, and JSON-RPC 2.0 as the protocol. This clear separation makes MCP easy to implement and universally applicable. In the next section, you will learn about the three primitives.