MCP Server Demo
A demonstration project for building MCP (Model Context Protocol) servers using the Python MCP SDK.
What is MCP?
The Model Context Protocol (MCP) allows applications to provide context for LLMs in a standardized way. This project demonstrates how to:
- Build MCP servers that expose resources, tools, and prompts
- Use the FastMCP framework for rapid development
- Run servers in development mode with hot reloading
Features
This demo server includes:
- Calculator Tools: Basic arithmetic operations
- Greeting Resources: Dynamic personalized greetings
- Code Review Prompts: Reusable templates for code review
- Development Mode: Hot reloading and debugging support
Installation
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Quick Start
Development Mode (Recommended)
Run the server in development mode with hot reloading:
mcp dev server.py
This will start the MCP Inspector where you can test your server interactively.
Direct Execution
Run the server directly:
python server.py
Claude Desktop Integration
Install the server in Claude Desktop:
mcp install server.py
Project Structure
mcp-server/
├── server.py # Main MCP server implementation
├── requirements.txt # Python dependencies
├── pyproject.toml # Project configuration
├── run_dev.py # Development runner script
└── README.md # This file
API Reference
Tools
add(a: int, b: int) -> int: Add two numbersmultiply(a: int, b: int) -> int: Multiply two numberscalculate_bmi(weight_kg: float, height_m: float) -> float: Calculate BMI
Resources
greeting://{name}: Get a personalized greeting for a given nameconfig://app: Get application configuration
Prompts
review_code: Template for code review requestsdebug_error: Template for debugging error messages
Development
The server uses FastMCP which provides:
- Automatic type validation
- Built-in error handling
- Development mode with hot reloading
- Easy integration with Claude Desktop
