A centralized FastAPI server that provides a unified interface for all Model Context Protocol (MCP) tools. This hub allows you to easily manage and interact with multiple MCP servers through a single API endpoint.
- Centralized API: Single endpoint for all MCP tools
- Dynamic Server Management: Add/remove Docker MCP servers effortlessly
- Multiple Transport Support: stdio, http, sse
- Interactive Documentation: Swagger UI and ReDoc
- Health Monitoring: Built-in health checks and status endpoints
- Environment Variable Management: Automatic configuration from .env files
- Docker Support: Run MCP servers in containers with proper isolation
- Python 3.11+
- Docker (for MCP servers)
- Git
-
Clone the repository:
git clone https://github.com/pranjal-pravesh/mcp-docker-hub.git cd mcp-docker-hub -
Set up environment variables:
cp env.example .env # Edit .env with your API keys -
Install dependencies:
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt pip install -e .
-
Start the hub:
python -m mcp_hub.mcp_hub_server --host 0.0.0.0 --port 8000 --load-config
-
Access the API:
- Main API: http://localhost:8000
- Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/
-
Create a Google Cloud VM (f1-micro recommended for free tier):
gcloud compute instances create mcp-hub \ --zone=us-central1-a \ --machine-type=f1-micro \ --image-family=ubuntu-2204-lts \ --image-project=ubuntu-os-cloud \ --tags=http-server,https-server \ --metadata=startup-script='#! /bin/bash curl -fsSL https://raw.githubusercontent.com/pranjal-pravesh/mcp-docker-hub/main/deploy-gcp.sh | bash'
-
SSH into the VM:
gcloud compute ssh mcp-hub --zone=us-central1-a
-
Run the deployment script:
curl -fsSL https://raw.githubusercontent.com/pranjal-pravesh/mcp-docker-hub/main/deploy-gcp.sh | bash
-
SSH into your VM:
gcloud compute ssh YOUR_VM_NAME --zone=YOUR_ZONE
-
Clone and run the deployment script:
git clone https://github.com/pranjal-pravesh/mcp-docker-hub.git cd mcp-docker-hub chmod +x deploy-gcp.sh ./deploy-gcp.sh
Allow port 8000 in your Google Cloud firewall:
gcloud compute firewall-rules create allow-mcp-hub \
--allow tcp:8000 \
--target-tags=http-server \
--description="Allow MCP Hub traffic"curl -X POST "http://localhost:8000/servers/add-docker" \
-H "Content-Type: application/json" \
-d '{
"name": "my-server",
"docker_image": "mcp/my-server",
"transport": "stdio",
"env_vars": {"API_KEY": "your-key"}
}'python scripts/manage_mcp_servers.py add \
--name my-server \
--docker-image mcp/my-server \
--transport stdio \
--env-vars '{"API_KEY": "your-key"}'Edit configs/mcp_servers.json:
{
"my-server": {
"docker_image": "mcp/my-server",
"transport": "stdio",
"env_vars": {
"API_KEY": "your-key"
}
}
}# Via API
curl -X DELETE "http://localhost:8000/servers/my-server"
# Via CLI
python scripts/manage_mcp_servers.py remove --name my-serverGET /- Server status and health checkGET /docs- Interactive API documentationGET /redoc- Alternative API documentation
GET /servers- List all MCP serversPOST /servers/start-all- Start all serversPOST /servers/stop-all- Stop all serversPOST /servers/add-docker- Add Docker MCP serverDELETE /servers/{name}- Remove server
GET /tools- List all available toolsGET /tools/qwen- Get enabled tools in Qwen format (JSON lines)GET /tools/qwen?required_only=true- Get enabled tools with only required parametersPOST /tools/call- Call any MCP toolGET /tools/info/{tool_name}- Get tool details
GET /servers/configured- List configured serversPOST /servers/load-config- Load from JSON configPOST /servers/save-config- Save to JSON configGET /servers/check-availability- Check server availability
-
Docker Permission Denied:
sudo usermod -aG docker $USER newgrp docker -
Port Already in Use:
sudo lsof -i :8000 sudo kill -9 <PID>
-
Environment Variables Not Loading:
python scripts/check_servers.py
-
Service Not Starting:
sudo systemctl status mcp-hub.service sudo journalctl -u mcp-hub.service -f
If you're currently using Docker-in-Docker and experiencing permission issues:
# Run the migration script
./migrate-to-direct.shThis will:
- Stop the Docker container
- Set up a Python virtual environment
- Create a systemd service
- Start the MCP Hub directly on the host
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.