Skip to content

CuriousCaliBoi/MCP_tutorial

Repository files navigation

Model Context Protocol (MCP) - Complete Tutorial

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.

🎯 What You'll Learn

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

📚 Tutorial Structure

This tutorial is organized as a progressive learning path:

Conceptual Understanding

  1. 01_what_is_mcp.md - Introduction to MCP and its purpose
  2. 02_core_concepts.md - Architecture, servers, clients, transports
  3. 03_mcp_tools.md - Understanding MCP Tools (function calling)
  4. 04_mcp_resources.md - Understanding MCP Resources (data access)
  5. 05_mcp_prompts.md - Understanding MCP Prompts (prompt templates)

Practical Implementation

  1. simple_server.py - Your first MCP server
  2. calculator_server.py - Building a tool-based server
  3. file_server.py - Building a resource-based server
  4. mcp_client.py - Connecting to MCP servers as a client
  5. mcp.py - Complete end-to-end example

🚀 Getting Started

Prerequisites

  • Python 3.10 or higher
  • Basic understanding of async/await in Python
  • Familiarity with JSON-RPC (helpful but not required)

Installation

# Install required dependencies
pip install -r requirements.txt

Quick Start

  1. Read the concepts (files 01-05) to understand MCP fundamentals
  2. 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
  3. Experiment by modifying the code and building your own servers!

🎓 Learning Path Recommendations

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!

🔑 Key Concepts at a Glance

  • 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)

💡 Why MCP Matters

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

🛠️ What You'll Build

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

📖 Additional Resources

🎉 Let's Begin!

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!

About

Complete tutorial on Model Context Protocol (MCP) - Learn how to build AI integrations with tools, resources, and prompts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages