The Model Context Protocol Book
A comprehensive guide for developers who want to understand, build, and deploy MCP servers and clients.
MCP is the open standard that connects AI applications to the tools and data they need. This book takes you from “what is MCP?” to “I’m running MCP servers in production.”
Who This Book Is For
- Backend developers building tools and APIs that AI agents should be able to use
- AI/ML engineers creating applications that need to interact with external systems
- Full-stack developers integrating MCP into existing products
- Technical leads evaluating MCP for their organization
- Anyone curious about how the sausage gets made when Claude checks the weather
No prior MCP knowledge required. Familiarity with JSON, APIs, and at least one programming language (TypeScript or Python preferred) will help.
Table of Contents
Part I: Understanding MCP
| Chapter | Title | What You’ll Learn |
|---|---|---|
| 01 | The Problem MCP Solves | Why MCP exists, the N-times-M integration nightmare, and MCP’s “USB-C moment” |
| 02 | Architecture | Hosts, clients, servers, trust boundaries, capability negotiation, and the three-layer cake |
| 03 | The Wire Protocol | JSON-RPC 2.0, message types, method catalog, initialization handshake, error codes, pagination, cancellation |
Part II: The Three Primitives
| Chapter | Title | What You’ll Learn |
|---|---|---|
| 04 | Tools | Tool definitions, schemas, annotations, discovery, invocation, result types, error handling, best practices |
| 05 | Resources | URIs, resource templates, subscriptions, binary data, audience annotations, resources vs. tools |
| 06 | Prompts | Prompt templates, arguments, multi-message prompts, embedded resources, practical patterns |
Part III: Transport and Communication
| Chapter | Title | What You’ll Learn |
|---|---|---|
| 07 | Transports | stdio, Streamable HTTP, legacy SSE, the proxy pattern, transport security, debugging transports |
Part IV: Building Things
| Chapter | Title | What You’ll Learn |
|---|---|---|
| 08 | Building Servers in TypeScript | McpServer API, Zod schemas, weather server example, HTTP transport, publishing to npm |
| 09 | Building Servers in Python | FastMCP, decorators, type hints, SQLite explorer example, uvx, publishing to PyPI |
| 10 | Building Clients | TypeScript and Python clients, building a host, managing multiple servers, the full agentic loop |
Part V: The Ecosystem
| Chapter | Title | What You’ll Learn |
|---|---|---|
| 11 | The SDK Landscape | All 10 official SDKs (TypeScript, Python, Go, C#, Java, Kotlin, Swift, Rust, Ruby, PHP), choosing an SDK |
| 12 | Configuration | Setting up MCP in Claude Desktop, Claude Code, VS Code, Cursor, and Windsurf |
Part VI: Security and Advanced Topics
| Chapter | Title | What You’ll Learn |
|---|---|---|
| 13 | Authentication and Security | OAuth 2.1, trust boundaries, threat modeling, security best practices for servers and hosts |
| 14 | Advanced Features | Sampling, elicitation, roots, completion, logging, progress reporting |
Part VII: Production and Beyond
| Chapter | Title | What You’ll Learn |
|---|---|---|
| 15 | Testing and Debugging | MCP Inspector, manual testing, common problems, testing strategies, debugging tips |
| 16 | Production Patterns | Deployment models, Docker/K8s, serverless, gateways, multi-tenancy, monitoring, scaling |
| 17 | The Ecosystem | Official servers, community servers, registries, discovery, evaluating and building for the ecosystem |
| 18 | The Future of MCP | Stateless protocol, server cards, transport evolution, agent convergence, the road ahead |
How to Read This Book
Linear path: Read chapters 1-18 in order for the complete journey from concepts to production.
Quick start: Read chapters 1-2 for the concepts, then jump to chapter 8 (TypeScript) or 9 (Python) to start building.
Reference: Each chapter is self-contained. Jump to whatever topic you need.
Architecture deep-dive: Chapters 2, 3, 7, and 13 cover the protocol in detail.
Practical guide: Chapters 8, 9, 10, 12, and 15 are hands-on with code and configuration.
About the Protocol
The Model Context Protocol was created by Anthropic and released as an open standard in November 2024. The specification is maintained at modelcontextprotocol.io and the source code is at github.com/modelcontextprotocol.
The current specification revision at time of writing is 2025-11-25.
Contributing
Found an error? Have a suggestion? Open an issue or pull request.
License
This book is available under the license specified in the LICENSE file.