Pranav Srivastava

10 lessons

0/10 done
Lesson 2 of 10·10 min·Beginner

How MCP Works

What you will learn
  • 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.

MCP Architecture — Host, Client, Server
  ┌────────────────────────────────────────────────────┐
  │  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)        │
  └──────────────────┘   └──────────────────┘
One host can have multiple clients, each connected to one server

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:

The Three MCP Primitives
  +-----------------------------------------------------+
  |  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 |
  +-----------------------------------------------------+
Tools are the most important — start there

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.

MCP Communication Flow — request / response pairs
  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.

Chapter summary
  • 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
Check your understanding
  1. What is the difference between a Host, a Client, and a Server in MCP?
  2. You want to give Claude the ability to send an email — which primitive do you use, and why?
  3. What does stdio transport mean, and why is it the right choice for local servers?

Finished this lesson?

Mark it done — your progress is saved automatically.