Multi-MCP Server
A distributed Model Context Protocol (MCP) server setup featuring multiple independent MCP servers and a master aggregator server. This project demonstrates how to build and orchestrate MCP-based services for tool calling and result aggregation.
๐ Features
Multiple MCP Servers: Three specialized MCP servers running on separate ports
Server 1: Greeting service
Server 2: Mathematical operations
Server 3: Text manipulation
Master Aggregator: A central MCP server that orchestrates calls to all three servers
HTTP Transport: Stateless HTTP-based communication using JSON-RPC 2.0
Async Support: Fully asynchronous implementation for high performance
Easy Deployment: Simple setup with virtual environment and uvicorn
๐ Prerequisites
Python 3.8+
Virtual environment (recommended)
๐ ๏ธ Installation
Clone the repository (if applicable) or navigate to the project directory:
cd /path/to/Multi-MCPServerCreate and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txt
๐โโ๏ธ Running the Servers
Start Individual MCP Servers
Run each server in separate terminals or background processes:
Start Master Aggregator Server
๐ Usage
Available Tools
Server 1 Tools
greet(name: str): Returns a personalized greeting message
Server 2 Tools
add(a: float, b: float): Returns the sum of two numbers
Server 3 Tools
reverse_text(text: str): Returns the reversed text
Master Server Tools
aggregate_results(input_text: str): Calls all three servers and aggregates their results
Example API Calls
Direct Server Calls
Aggregated Results
Response:
๐๏ธ Architecture
Master Server: Orchestrates calls to individual servers
Individual Servers: Specialized MCP servers with unique tools
HTTP Transport: All communication uses HTTP with JSON-RPC 2.0 over Server-Sent Events
๐ง Configuration
Ports: Configurable via
PORTenvironment variable (defaults: 8001, 8002, 8003)Host: Default
0.0.0.0for external accessTransport Security: Configurable via
TransportSecuritySettings
๐งช Testing
Run the servers and use the provided curl examples to test functionality.
๐ฆ Dependencies
fastmcp: MCP server frameworkhttpx: Async HTTP clientuvicorn: ASGI serverfastapi: Web framework
See requirements.txt for full list.
๐ค Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Troubleshooting
Common Issues
Port already in use: Change the PORT environment variable
Connection refused: Ensure all servers are running
JSON parsing errors: Check request format matches JSON-RPC 2.0 specification
Logs
Check server logs for detailed error information. Enable debug logging by setting LOG_LEVEL=DEBUG.
๐ Additional Resources
JSON-RPC 2.0 Specification /Users/arvindacharya/Desktop/Quadra-Projects/MCP/Multi-MCPServer/README.md