Welcome! This tutorial will teach you everything you need to know about the Model Context Protocol (MCP), a powerful standard for connecting AI assistants to external tools, data sources, and services.
By working through this tutorial, you'll understand:
- What MCP is and why it's revolutionary
- The core architecture and components
- How to build MCP servers and clients
- Working with Tools, Resources, and Prompts
- Real-world practical implementations
This tutorial is organized as a progressive learning path:
- 01_what_is_mcp.md - Introduction to MCP and its purpose
- 02_core_concepts.md - Architecture, servers, clients, transports
- 03_mcp_tools.md - Understanding MCP Tools (function calling)
- 04_mcp_resources.md - Understanding MCP Resources (data access)
- 05_mcp_prompts.md - Understanding MCP Prompts (prompt templates)
- simple_server.py - Your first MCP server
- calculator_server.py - Building a tool-based server
- file_server.py - Building a resource-based server
- mcp_client.py - Connecting to MCP servers as a client
- mcp.py - Complete end-to-end example
- Python 3.10 or higher
- Basic understanding of async/await in Python
- Familiarity with JSON-RPC (helpful but not required)
# Install required dependencies
pip install -r requirements.txt- Read the concepts (files 01-05) to understand MCP fundamentals
- Run the examples to see MCP in action:
# Start a simple server python simple_server.py # In another terminal, run the client python mcp_client.py
- Experiment by modifying the code and building your own servers!
If you're new to MCP:
- Start with 01_what_is_mcp.md
- Read through 02_core_concepts.md carefully
- Run simple_server.py and examine the code
- Progress through the other examples
If you're experienced with APIs:
- Skim 01 and 02 for MCP-specific concepts
- Jump to 03, 04, 05 for the three core primitives
- Study the Python implementations
- Build your own server for a real use case
If you learn best by doing:
- Read 01_what_is_mcp.md for context
- Jump straight to simple_server.py
- Refer back to concept docs as needed
- Experiment and break things!
- MCP Server: Exposes tools, resources, and prompts to AI assistants
- MCP Client: Connects to servers and uses their capabilities (often the AI assistant)
- Tools: Functions the AI can call (like "search the web" or "read a file")
- Resources: Data the AI can access (like files, database records, or API responses)
- Prompts: Reusable prompt templates with variables
- Transport: How client and server communicate (stdio, HTTP, WebSocket)
Before MCP, every AI assistant needed custom integrations for every tool or data source. MCP provides a universal standard, meaning:
- ✅ Write once, use with any MCP-compatible AI
- ✅ Plug-and-play architecture
- ✅ Secure, standardized communication
- ✅ Composable and extensible
By the end of this tutorial, you'll have built:
- A calculator server with mathematical tools
- A file system server exposing resources
- A client that can connect to any MCP server
- A complete integrated example
Start your journey by opening 01_what_is_mcp.md and let's dive into the exciting world of Model Context Protocol!
Remember: The best way to learn is by doing. Don't just read—run the code, modify it, break it, and rebuild it!