Skip to content

MaxGrosshandler/mcp-learning

Repository files navigation

MCP Explained - Interactive Learning Platform

A comprehensive, interactive web-based guide to understanding the Model Context Protocol (MCP) and how to build with it.

Overview

MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems, data sources, and tools. This project provides:

  • Educational Content: Learn what MCP is, why it matters, and how it works
  • Architecture Deep-Dive: Understand the client-server model and JSON-RPC communication
  • Real-World Use Cases: Explore practical applications across industries
  • Getting Started Guide: Build your first MCP server with examples
  • Interactive Demonstrations: Visualize MCP communication in action

Features

📚 Learning Paths

  1. What is MCP? - Introduction to core concepts
  2. Architecture - Deep dive into how MCP works
  3. Use Cases - Real-world applications and examples
  4. Getting Started - Hands-on tutorials and code examples

🎨 Interactive Elements

  • Animated component diagrams
  • Interactive flow demonstrations
  • Code examples in Node.js and Python
  • Visual explanations of concepts

📱 Responsive Design

  • Mobile-friendly interface
  • Works on all devices
  • Smooth animations and transitions
  • Accessible navigation

Quick Start

Prerequisites

  • Node.js 14+ or higher
  • npm or yarn

Installation

  1. Clone or download this project

  2. Navigate to the project directory:

    cd MCP
  3. Install dependencies:

    npm install
  4. Start the development server:

    npm start
  5. Open your browser and navigate to:

    http://localhost:3000
    

Project Structure

MCP/
├── server.js              # Express server
├── package.json           # Dependencies
├── README.md             # This file
├── public/               # Static files
│   ├── styles.css        # Main stylesheet
│   ├── app.js            # General app functionality
│   └── demo.js           # Interactive demo logic
└── views/                # EJS templates
    ├── index.ejs         # Home page
    ├── what-is-mcp.ejs   # MCP basics
    ├── architecture.ejs  # Technical deep-dive
    ├── use-cases.ejs     # Real-world applications
    └── getting-started.ejs # Implementation guide

Content Overview

Home Page

  • Introduction to MCP
  • Quick overview of key features
  • Navigation to learning modules
  • Visual diagram of MCP concept

What is MCP?

  • Definition and purpose
  • Three main capabilities (data, tools, workflows)
  • Problem it solves
  • Benefits for developers, AI apps, and users
  • Real-world analogy

Architecture

  • Client-server model
  • JSON-RPC 2.0 protocol
  • Core components (Resources, Tools, Prompts)
  • Request-response flow
  • Message types
  • Transport mechanisms
  • Interactive demonstration

Use Cases

  • Business Intelligence & Analytics
  • Knowledge Management
  • Development & Coding
  • Customer Service
  • Content Creation
  • Research & Analysis
  • System Administration
  • Legacy System Integration

Getting Started

  • Prerequisites and setup
  • Node.js example implementation
  • Python example implementation
  • Step-by-step guide
  • Common patterns
  • Testing and best practices

Key Concepts Explained

Resources

Data sources that AI applications can read from:

  • Files and documents
  • Database records
  • API responses
  • Real-time data streams

Tools

Functions that AI applications can call:

  • Database queries
  • External API calls
  • System operations
  • Custom computations

Prompts

Reusable prompt templates and instructions:

  • Domain-specific instructions
  • Custom system prompts
  • Workflow definitions
  • Task templates

Communication Protocol

MCP uses JSON-RPC 2.0 for standardized communication:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "resources/list",
  "params": {}
}

Building Your First MCP Server

Simple Node.js Example

const { Server } = require('@modelcontextprotocol/sdk');

const server = new Server({
  name: "my-server",
  version: "1.0.0"
});

// Define resources
server.setResourceHandler(async () => {
  return {
    resources: [
      {
        uri: "data://resource1",
        name: "Resource 1",
        mimeType: "application/json"
      }
    ]
  };
});

// Define tools
server.setToolHandler(async (toolName, toolInput) => {
  if (toolName === "my_tool") {
    return {
      content: [{
        type: "text",
        text: "Tool executed successfully"
      }]
    };
  }

  throw new Error(`Unknown tool: ${toolName}`);
});

server.start(process.stdin, process.stdout);

Common Patterns

  1. Database Connection: Connect MCP to query databases
  2. File System Access: Expose files via MCP
  3. External API Integration: Wrap APIs as MCP tools
  4. Real-time Data Streams: Subscribe to live data
  5. Authentication & Authorization: Secure access

Development

Running Locally

npm install
npm run dev

The server will start on http://localhost:3000

Building for Production

npm run build
npm start

Learning Resources

Best Practices

  1. Error Handling: Always handle errors gracefully
  2. Documentation: Clearly document resources and tools
  3. Security: Validate inputs and implement access controls
  4. Performance: Cache data and optimize queries
  5. Logging: Log important events
  6. Versioning: Maintain backwards compatibility

Architecture Overview

┌─────────────────┐         JSON-RPC 2.0          ┌──────────────────┐
│   AI Client     │ ◄──────────────────────────► │    MCP Server    │
│   (Claude, etc) │                                │ (Your Service)   │
└─────────────────┘                                └──────────────────┘
                                                           │
                                                   ┌───────┴─────────┐
                                                   │                 │
                                          ┌────────▼──────┐  ┌────────▼──────┐
                                          │    Resources  │  │     Tools     │
                                          │   (Data API)  │  │  (Functions)  │
                                          └───────────────┘  └───────────────┘

FAQ

Q: What is MCP used for? A: MCP enables AI applications to connect to external systems, data sources, and tools in a standardized way.

Q: Do I need to use MCP with Claude? A: No, MCP is compatible with any AI application that supports it.

Q: Can I build an MCP server in any language? A: Yes! SDKs are available for Node.js, Python, and more. You can also implement the JSON-RPC 2.0 protocol directly.

Q: Is MCP secure? A: MCP provides standardized patterns for security, but security depends on proper implementation. Always validate inputs and use authentication.

Q: How do I deploy an MCP server? A: You can deploy on any hosting platform that supports your language (AWS, Azure, Google Cloud, etc.).

Contributing

This is an educational project. Feel free to fork, modify, and use it for learning purposes.

License

MIT License - Feel free to use this project for learning and teaching.

Contact & Support

For issues or questions:


Happy Learning! 🚀

Start with the home page and follow the learning path to become an MCP expert.

About

A tool made by Claude Code to help teach people about MCP (Model Context Protocol)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors