A practical guide to extending AI assistants with your own tools, data, and workflows using the Model Context Protocol.
The Model Context Protocol (MCP) is an open standard created by Anthropic that defines how AI models connect to external tools and data sources. Think of it as a universal adapter — like USB-C for AI — that lets any MCP-compatible application (Claude Desktop, Claude Code, Cursor, and many others) connect to any MCP server you build.
Before MCP, every AI integration was bespoke: a custom plugin for one app, a different API wrapper for another, brittle and non-portable. MCP changes that. You write a server once, and any compatible client can use it.
This book walks you through MCP from the ground up: what the protocol does, how to write your own server in Python, and how to connect it to the applications you already use.
The book is organized in four parts:
Part 1 — Foundations (Chapters 0–1): What MCP is and how its architecture works.
Part 2 — Building a Server (Chapters 2–6): Step-by-step guide to writing MCP servers in Python, covering tools, resources, prompts, and transport options.
Part 3 — Connecting to Clients (Chapters 7–9): Practical configuration for Claude Desktop, Claude Code, Cursor, and building a custom client.
Part 4 — Going Further (Chapters 10–11): Authentication, advanced features, production patterns, and an action plan.
All code examples use Python 3.11+ and the mcp Python SDK (pip install mcp). Longer code examples live in the code/ subdirectory and are referenced from the text. Shorter snippets (≤20 lines) appear inline.
The MCP specification and SDK evolve quickly. This guide was written against the MCP spec as of early 2026. When in doubt, check the official MCP documentation.