Chapter 37: Model Context Protocol (MCP) Fundamentals
Every AI application needs to connect to external systems—databases, file systems, project trackers, knowledge bases. Without a standard protocol, you'd build custom integrations for each combination: Claude + GitHub, ChatGPT + GitHub, Cursor + GitHub... the work multiplies unsustainably.
MCP (Model Context Protocol) solves this integration explosion. It's the USB-C of AI applications: one protocol that connects any AI host to any external service. Write an MCP server once, and it works with Claude, ChatGPT, Cursor, VS Code, and every other MCP-compatible application instantly.
Introduced by Anthropic in November 2024, adopted by OpenAI in March 2025, and donated to the Linux Foundation's Agentic AI Foundation in December 2025, MCP has evolved from one company's solution to industry infrastructure. Claude Code, Cursor, ChatGPT, Gemini, VS Code, and dozens of other tools already speak MCP. When you add an MCP server to your environment, every MCP-compatible agent gains those capabilities—no code changes required.
This chapter teaches MCP from first principles. You'll understand the protocol architecture, learn to use existing MCP servers effectively, and prepare for Chapter 38 where you'll build your own.
What You'll Learn
By the end of this chapter, you'll be able to:
- Understand MCP architecture: Grasp the Host-Client-Server model, transport layers (stdio, Streamable HTTP), and the three primitives (tools, resources, prompts)
- Configure MCP servers: Set up MCP servers in Claude Code, Claude Desktop, Cursor, and other clients using JSON configuration
- Use tools effectively: Understand tool schemas, invoke tools correctly, and handle tool results
- Access resources: Read files, database records, and API data through MCP's resource abstraction
- Leverage prompts: Use server-provided prompt templates that encode domain expertise
- Debug MCP connections: Diagnose connection issues, trace message flow, and resolve common problems
Chapter Structure
| # | Lesson | Duration | Description |
|---|---|---|---|
| 1 | MCP Architecture Overview | 14 min | The integration explosion problem, Host-Client-Server model, and protocol design |
| 2 | Transport Layers | 15 min | stdio for local servers, Streamable HTTP for remote, HTTP fundamentals primer, and when to use each |
| 3 | Tools: The Model-Controlled Primitive | 14 min | Executable functions that LLMs invoke to perform actions |
| 4 | Resources: The App-Controlled Primitive | 12 min | Read-only data sources that provide context to AI |
| 5 | Prompts: The User-Controlled Primitive | 12 min | Pre-crafted instruction templates encoding domain expertise |
| 6 | Configuring MCP Clients | 14 min | Setup in Claude Code, Claude Desktop, Cursor, VS Code, and programmatic clients |
| 7 | Using Community MCP Servers | 15 min | Filesystem, GitHub, databases, and other popular servers |
| 8 | Debugging and Troubleshooting | 12 min | MCP Inspector, connection diagnostics, and common error patterns |
| 9 | Chapter Quiz | 15 min | Test your understanding of MCP fundamentals |
Total Chapter Duration: ~2 hours 5 min
Prerequisites
- Chapters 34-36: Agent SDK experience (understanding of tool use in OpenAI, Claude, and Google SDKs)
- Chapter 3: Claude Code mastery (you've used MCP without knowing it)
- Part 5: Python Fundamentals (for understanding server implementations)
Key Concepts
The Three Primitives
| Primitive | Controller | Purpose | Example |
|---|---|---|---|
| Tools | Model-controlled | Perform actions | github_create_issue, read_file |
| Resources | App-controlled | Read data | docs://documents/{id}, db://users |
| Prompts | User-controlled | Instruction templates | summarize_document, code_review |
Transport Options
| Transport | Best For | Clients | Complexity |
|---|---|---|---|
| stdio | Local development, desktop apps | Single | Low |
| Streamable HTTP | Production, cloud deployment | Multiple | Medium |
What's Next
After completing this chapter, you'll be ready for:
- Chapter 38: MCP Server Development — Build your own MCP servers to expose your tools and data
- Chapter 39: Code Execution with MCP — Execute code safely within MCP servers