Skip to main content

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

#LessonDurationDescription
1MCP Architecture Overview14 minThe integration explosion problem, Host-Client-Server model, and protocol design
2Transport Layers15 minstdio for local servers, Streamable HTTP for remote, HTTP fundamentals primer, and when to use each
3Tools: The Model-Controlled Primitive14 minExecutable functions that LLMs invoke to perform actions
4Resources: The App-Controlled Primitive12 minRead-only data sources that provide context to AI
5Prompts: The User-Controlled Primitive12 minPre-crafted instruction templates encoding domain expertise
6Configuring MCP Clients14 minSetup in Claude Code, Claude Desktop, Cursor, VS Code, and programmatic clients
7Using Community MCP Servers15 minFilesystem, GitHub, databases, and other popular servers
8Debugging and Troubleshooting12 minMCP Inspector, connection diagnostics, and common error patterns
9Chapter Quiz15 minTest 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

PrimitiveControllerPurposeExample
ToolsModel-controlledPerform actionsgithub_create_issue, read_file
ResourcesApp-controlledRead datadocs://documents/{id}, db://users
PromptsUser-controlledInstruction templatessummarize_document, code_review

Transport Options

TransportBest ForClientsComplexity
stdioLocal development, desktop appsSingleLow
Streamable HTTPProduction, cloud deploymentMultipleMedium

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

Resources