Model Context Protocol (MCP) Server

by ellenfel

130 downloads
Not rated
GitHub

About

A basic educational implementation of the Model Context Protocol (MCP) in Python. It demonstrates core MCP concepts using FastAPI, WebSockets, and Pydantic for message handling. Designed for learning and experimentation.

Details

Author
ellenfel
Downloads
130
Categories
Other

- WebSocket-based communication using FastAPI
- Basic MCP message handling with Pydantic models
- Support for model context management
- Simple client-server interaction with async/await
- Pythonic code structure for educational clarity

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Model Context Protocol (MCP) Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Create a virtual environment, install dependencies from requirements.txt, start the server with python -m src.server, and run the example client with python examples/basic_usage.py.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "model context protocol (mcp) server": {
            "model-context-protocol-ellenfel": {
                "command": "python",
                "args": [
                    "-m",
                    "venv",
                    "venv"
                ]
            }
        }
    }
}

McpServers

{
    "model-context-protocol-ellenfel": {
        "command": "python",
        "args": [
            "-m",
            "venv",
            "venv"
        ]
    }
}

Model Context Protocol (MCP) Server

A basic implementation of a Model Context Protocol server for educational purposes. This server demonstrates the core concepts of MCP and how to implement them in practice using Python.

Features

- WebSocket-based communication using FastAPI and WebSockets
- Basic MCP message handling with Pydantic models
- Support for model context management
- Simple client-server interaction
- Async/await support for better performance

Getting Started

1. Create a virtual environment (recommended):

python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

2. Install dependencies:

pip install -r requirements.txt

3. Start the development server:

python -m src.server

4. Run the example client:

python examples/basic_usage.py

Project Structure

src/
├── server.py          # Main server implementation
├── types/            # TypeScript type definitions
│   └── mcp.py        # MCP protocol types using Pydantic
└── examples/         # Example implementations
    └── basic_usage.py # Basic client example

MCP Protocol Overview

The Model Context Protocol (MCP) is a communication protocol designed for AI model interactions. This implementation includes:

- Message format handling using Pydantic models
- Context management
- Basic protocol operations
- Async/await support for better performance

Key Differences from TypeScript Version

1. Uses FastAPI instead of Express
2. Implements async/await for better performance
3. Uses Pydantic for data validation and serialization
4. More Pythonic code structure and patterns
MIT

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.