Day 1:Week 14, Day 1: `MCP` Architecture (`Host`, `Client`, `Server`) & Wire-Level `JSON-RPC 2.0` Protocol
Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz
Week 14, Day 1: MCP Architecture (Host, Client, Server) & Wire-Level JSON-RPC 2.0 Protocol
1. Why MCP Solved the Integration Bottleneck
Before the Model Context Protocol (MCP) (introduced by Anthropic and adopted across IDEs, agents, and cloud platforms), connecting AI applications (Claude Desktop, Cursor, Antigravity, custom FastAPI agents) to data sources (Postgres, GitHub, Kubernetes, Slack, Jira) required writing bespoke connectors!
MCP acts as the "USB-C Port for AI Applications", reducing to :
┌─────────────────────────────────────────────────────────────────────────┐
│ MCP HOST (e.g., AI IDE, FastAPI Agent Backend) │
│ ├── MCP Client 1 ◄══ JSON-RPC 2.0 (stdio / HTTP) ══► MCP Server: GitHub│
│ ├── MCP Client 2 ◄══ JSON-RPC 2.0 (stdio / HTTP) ══► MCP Server: K8s │
│ └── MCP Client 3 ◄══ JSON-RPC 2.0 (stdio / HTTP) ══► MCP Server: SQLite│
└─────────────────────────────────────────────────────────────────────────┘
2. Wire-Level JSON-RPC 2.0 Specification in MCP
Every message exchanged between an MCP Client and MCP Server is a valid JSON-RPC 2.0 packet:
- Request (Requires
id):json{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}} - Notification (No
idfield — one-way event):json{"jsonrpc": "2.0", "method": "notifications/initialized"} - Success Response (Echoes matching
id):json{"jsonrpc": "2.0", "id": 1, "result": {"tools": [...]}} - Error Response (Standard JSON-RPC 2.0 Error Codes):
-32700: Parse error (Invalid JSON)-32600: Invalid Request (Missing"jsonrpc": "2.0")-32601: Method not found (Unknown MCP method)-32602: Invalid params (Missing or malformed tool/resource parameters)-32603: Internal error
In Simple English: MCP = The USB-C Port for AI Agents
Before USB-C, every phone needed a separate custom charger. Before MCP (Model Context Protocol), connecting 5 AI apps (Claude, Cursor, Windsurf, Custom Agent, Chat UI) to 10 tools (Postgres, GitHub, Slack, Jira...) required writing $5 \times 10 = 50$ fragile custom adapters!
With MCP:
- Build 1 MCP Server once for your Postgres database or Runbook folder.
- ANY MCP Host/Client snaps right into it cleanly over standard
JSON-RPC 2.0messages (initialize,tools/list,tools/call) — turning chaos into simple plug-and-play!