mcp-protocol-server

tian1ll1/mcp-protocol-server

3.1

If you are the rightful owner of mcp-protocol-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A FastAPI-based implementation of a Model Context Protocol (MCP) server that handles model context management, session handling, and protocol operations.

Model Context Protocol Server

A FastAPI-based implementation of a Model Context Protocol (MCP) server that handles model context management, session handling, and protocol operations.

Features

  • FastAPI-based REST API server
  • Model context management
  • Session handling and persistence
  • WebSocket support for real-time updates
  • Authentication and authorization
  • Request validation and error handling
  • Swagger/OpenAPI documentation
  • Docker support

Project Structure

mcp-protocol-server/
ā”œā”€ā”€ app/
│   ā”œā”€ā”€ __init__.py
│   ā”œā”€ā”€ main.py
│   ā”œā”€ā”€ config.py
│   ā”œā”€ā”€ core/
│   │   ā”œā”€ā”€ __init__.py
│   │   ā”œā”€ā”€ context.py
│   │   ā”œā”€ā”€ session.py
│   │   └── protocol.py
│   ā”œā”€ā”€ api/
│   │   ā”œā”€ā”€ __init__.py
│   │   ā”œā”€ā”€ endpoints/
│   │   │   ā”œā”€ā”€ __init__.py
│   │   │   ā”œā”€ā”€ context.py
│   │   │   └── session.py
│   │   └── dependencies.py
│   ā”œā”€ā”€ models/
│   │   ā”œā”€ā”€ __init__.py
│   │   ā”œā”€ā”€ context.py
│   │   └── session.py
│   └── utils/
│       ā”œā”€ā”€ __init__.py
│       └── security.py
ā”œā”€ā”€ tests/
│   ā”œā”€ā”€ __init__.py
│   ā”œā”€ā”€ conftest.py
│   ā”œā”€ā”€ test_context.py
│   └── test_session.py
ā”œā”€ā”€ docker/
│   ā”œā”€ā”€ Dockerfile
│   └── docker-compose.yml
ā”œā”€ā”€ requirements.txt
ā”œā”€ā”€ .env.example
└── README.md

Installation

  1. Clone the repository:
git clone https://github.com/tian1ll1/mcp-protocol-server.git
cd mcp-protocol-server
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Copy the example environment file and configure your settings:
cp .env.example .env

Running the Server

Development Mode

uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Production Mode

uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4

Using Docker

docker-compose up -d

API Documentation

Once the server is running, you can access the API documentation at:

Testing

Run the test suite:

pytest

Configuration

The server can be configured using environment variables or a .env file. See .env.example for available options.

License

This project is licensed under the MIT License - see the LICENSE file for details.