How MCP Works
- Understand the three-part architecture: Host, Client, Server
- Learn the three MCP primitives: Tools, Resources, Prompts
- Understand JSON-RPC communication and the two transport options
The three components
Every MCP setup has three distinct pieces. Understanding which is which will prevent a lot of confusion.
┌────────────────────────────────────────────────────┐
│ Host (e.g. Claude Desktop) │
│ │
│ ┌────────────────┐ ┌────────────────┐ │
│ │ MCP Client 1 │ │ MCP Client 2 │ ... │
│ └───────┬────────┘ └───────┬────────┘ │
└──────────┼─────────────────────┼───────────────────┘
│ MCP protocol │ MCP protocol
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ Your File │ │ Your Database │
│ MCP Server │ │ MCP Server │
│ (Python) │ │ (Python) │
└──────────────────┘ └──────────────────┘
Host — the AI application the user interacts with. Examples: Claude Desktop, Claude Code, a custom AI app you build.
Client — the MCP client lives inside the host. It manages the connection to exactly one MCP server. If you have three MCP servers connected, the host creates three clients.
Server — the thing you build. A separate process (Python, TypeScript, or any language) that exposes tools, resources, and prompts to the AI.
The three primitives
Every MCP server can expose up to three types of things:
+-----------------------------------------------------+
| Primitive | What it is | When to use |
+-----------------------------------------------------+
| Tools | Functions the AI | When you want |
| | can call | the AI to DO |
| | e.g. read_file() | something |
+-----------------------------------------------------+
| Resources | Data sources the | When you want |
| | AI can read | the AI to READ|
| | e.g. notes://list | something |
+-----------------------------------------------------+
| Prompts | Reusable prompt | When you want |
| | templates | standard ways |
| | e.g. /summarise | to ask things |
+-----------------------------------------------------+
How communication works
MCP uses JSON-RPC 2.0 — a simple message format. Every message is JSON. The AI sends a request, the server sends a response.
AI Client MCP Server
| |
|-- initialize ──────────────────────►|
|◄─ capabilities (tools list) ────────|
| |
|-- tools/list ──────────────────────►|
|◄─ [{name, description, schema}] ───|
| |
|-- tools/call {read_file, args} ────►|
|◄─ {content: "file contents..."} ───|
| |
|-- tools/call {save_note, args} ────►|
|◄─ {content: "Saved."} ─────────────|
Transport: how they connect
stdio — the host launches your MCP server as a child process and communicates through stdin/stdout. Fast, simple, no network needed. This is how local MCP servers work and what you will use in this course.
Streamable HTTP — the server runs as an HTTP endpoint. Used for remote MCP servers deployed to the cloud.
- A Host contains one Client per connected MCP Server
- Three primitives: Tools (actions), Resources (data), Prompts (templates)
- Communication uses JSON-RPC 2.0 — simple request/response pairs
- Local servers use stdio transport; remote servers use Streamable HTTP
- What is the difference between a Host, a Client, and a Server in MCP?
- You want to give Claude the ability to send an email — which primitive do you use, and why?
- What does stdio transport mean, and why is it the right choice for local servers?