No project description provided
Project description
โจ MCP Compose
Similar to Docker Compose - Orchestrate Model Context Protocol (MCP) servers with management capabilities, REST API, and Web UI.
๐ฏ Overview
MCP Compose is a comprehensive solution for managing multiple MCP servers in a unified environment. It provides automatic discovery, intelligent composition, protocol translation, real-time monitoring, and a beautiful web interface for managing your MCP infrastructure.
Key Capabilities
๐ง Multi-Server Management - Start, stop, and monitor multiple MCP servers from a single interface
๐ REST API - Complete REST API with 32 endpoints for programmatic control
๐จ Modern Web UI - Beautiful React-based interface with real-time updates
๐ Protocol Translation - Seamlessly translate between STDIO and SSE protocols
๐ Real-Time Monitoring - Live metrics, logs, and health checks
๐ Security First - Token authentication, CORS support, rate limiting
๐ฆ Easy Deployment - Docker support with docker-compose orchestration
๐งช Well Tested - 95% test coverage with 265+ tests
๐ Comprehensive Docs - Full API reference, user guide, and deployment guide
๐ Quick Start
Installation
# Install from PyPI
pip install mcp-compose
# Or install from source
git clone https://github.com/datalayer/mcp-compose.git
cd mcp-compose
pip install -e .
Using Docker (Recommended)
# Clone repository
git clone https://github.com/datalayer/mcp-compose.git
cd mcp-compose
# Start with docker-compose (includes Prometheus & Grafana)
docker-compose up -d
# Access the Web UI
open http://localhost:8000
Using CLI
# Start the server with Web UI
mcp-composer serve --config examples/mcp_compose.toml
# Access Web UI at http://localhost:8000
# Access API at http://localhost:8000/api/v1
# Access API docs at http://localhost:8000/docs
# Discover available MCP servers
mcp-composer discover
# Invoke a tool
mcp-composer invoke-tool calculator:add '{"a": 5, "b": 3}'
Using Python API
from mcp_compose import MCPServerComposer
# Create composer and start servers
composer = MCPServerComposer()
composer.load_config("config.toml")
# Start all servers
for server in composer.servers.values():
await composer.start_server(server.name)
# List available tools
tools = await composer.list_tools()
print(f"Available tools: {[t.name for t in tools]}")
# Invoke a tool
result = await composer.invoke_tool("calculator:add", {"a": 5, "b": 3})
print(f"Result: {result}")
๐จ Web UI Features
The modern web interface provides:
- ๐ Dashboard - Overview of all servers, tools, and system metrics
- ๐ฅ๏ธ Server Management - Start, stop, restart servers with real-time status
- ๐ง Tool Browser - Search and invoke tools with interactive forms
- โ๏ธ Configuration Editor - Edit and validate configuration files
- ๐ Log Viewer - Real-time log streaming with filtering
- ๐ Metrics Dashboard - Charts for CPU, memory, and request metrics
- ๐ Translator Management - Create and manage protocol translators
- โ๏ธ Settings - Configure theme, API settings, and preferences
๐ Documentation
- User Guide - Complete guide for using MCP Compose
- API Reference - Full REST API and Python API documentation
- Deployment Guide - Production deployment with Docker & Kubernetes
- Architecture - System architecture and design decisions
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Web UI (React) โ
โ Dashboard โ Servers โ Tools โ Config โ Logs โ Metrics โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP/WebSocket
โโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REST API (FastAPI) โ
โ /servers โ /tools โ /config โ /translators โ /metrics โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Compose Core โ
โ Server Manager โ Tool Broker โ Config Manager โ
โโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโ
โ โ โ โ
โโโโโโดโโโโ โโโโโดโโโโโ โโโโโดโโโโโ โโโโโดโโโโโ
โ Server โ โ Server โ โ Server โ โ Server โ
โ A โ โ B โ โ C โ โ D โ
โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ
โจ Core Features
Server Management
โจ Core Features
Server Management
- Multi-Server Orchestration - Run multiple MCP servers simultaneously
- Lifecycle Management - Start, stop, restart, and monitor server health
- Auto-restart - Automatically restart failed servers
- Environment Isolation - Each server runs in its own isolated environment
- Configuration Hot-Reload - Update configuration without restarting
Tool & Prompt Composition
- Automatic Discovery - Find tools and prompts from all running servers
- Intelligent Composition - Combine capabilities from multiple sources
- Conflict Resolution - Handle naming conflicts with prefix/suffix/override strategies
- Dynamic Loading - Tools appear as servers start
- Unified Interface - Single API to access all tools
Protocol Translation
- STDIO โ SSE - Translate between different transport protocols
- Transparent Bridging - No changes needed to existing servers
- Bidirectional - Full request/response support
- Multiple Translators - Run many translators simultaneously
Monitoring & Observability
- Real-Time Metrics - CPU, memory, request rates, and latency
- Structured Logging - JSON logs with correlation IDs
- Health Checks - Continuous monitoring of server health
- Prometheus Integration - Export metrics for Prometheus
- WebSocket Streaming - Live log and metric updates
Security
- Token Authentication - Secure API access
- CORS Support - Configurable origin policies
- Rate Limiting - Prevent abuse
- Input Validation - Comprehensive request validation
- Non-root Containers - Run as unprivileged user
๐ ๏ธ Configuration
Create mcp_compose.toml:
[composer]
name = "my-composer"
conflict_resolution = "prefix"
[[servers]]
name = "filesystem"
command = "python"
args = ["-m", "mcp_server_filesystem", "/data"]
transport = "stdio"
auto_start = true
[[servers]]
name = "calculator"
command = "python"
args = ["-m", "mcp_server_calculator"]
transport = "stdio"
auto_start = true
[logging]
level = "INFO"
format = "json"
[security]
auth_enabled = true
cors_origins = ["http://localhost:3000"]
See User Guide for complete configuration options.
๐ REST API
Key Endpoints
# Health & Status
GET /api/v1/health
GET /api/v1/version
GET /api/v1/status
GET /api/v1/status/composition
# Server Management
GET /api/v1/servers
POST /api/v1/servers/{id}/start
POST /api/v1/servers/{id}/stop
POST /api/v1/servers/{id}/restart
# Tool Management
GET /api/v1/tools
POST /api/v1/tools/{name}/invoke
# Configuration
GET /api/v1/config
PUT /api/v1/config
POST /api/v1/config/validate
POST /api/v1/config/reload
# Translators
GET /api/v1/translators
POST /api/v1/translators
DELETE /api/v1/translators/{id}
# WebSocket
WS /ws/logs
WS /ws/metrics
See API Reference for complete documentation.
๐งช Testing
# Run all tests
make test
# Run with coverage
make test-coverage
# Run specific test
pytest tests/test_composer.py -v
# Type checking
make type-check
# Linting
make lint
๐ฆ Development
# Clone repository
git clone https://github.com/datalayer/mcp-compose.git
cd mcp-compose
# Install development dependencies
pip install -e ".[dev]"
# Install UI dependencies
cd ui
npm install
npm run dev
# Run tests
make test
# Build UI
make build-ui
# Run server
mcp-composer serve
๐ณ Docker Deployment
Quick Start
# Build and run
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose down
Production Deployment
# Build with production settings
docker build -t mcp-composer:prod .
# Run with environment variables
docker run -d \
-p 8000:8000 \
-v $(pwd)/config.toml:/app/config.toml:ro \
-e MCP_COMPOSER_AUTH_TOKEN=secret \
--name mcp-composer \
mcp-composer:prod
See Deployment Guide for Kubernetes and production setup.
๐ Examples
Git + File MCP Servers
A complete example demonstrating how to orchestrate Git and Filesystem MCP servers with anonymous access.
Location: examples/git-file/
Features:
- Git operations (status, log, diff, commit)
- Filesystem operations (read, write, list)
- Unified API with tool prefixing
- No authentication required
- Full Makefile for easy management
Quick Start:
cd examples/git-file
make install
make start
make open-ui
See the Git-File Example README for complete documentation.
OAuth Authentication Example
Production-ready example with GitHub OAuth2 authentication.
Location: references/oauth/
Features:
- OAuth2 authentication flow
- JWT tokens
- Protected MCP server endpoints
- Pydantic AI agent integration
See the MCP Auth Example README for details.
๐๏ธ Resources
Configuration files and infrastructure resources are located in the resources/ directory:
nginx.conf- Nginx reverse proxy configurationprometheus.yml- Prometheus metrics collectiongrafana/- Grafana dashboards and datasources
๐ Project Status
Phase 4: Complete โ
Week 13-16 Deliverables:
- โ Modern React-based Web UI with 8 pages
- โ Real-time monitoring dashboard
- โ Log viewer with streaming
- โ Metrics visualization with Recharts
- โ Protocol translator management
- โ Settings and preferences
- โ Comprehensive documentation
- โ Docker deployment setup
- โ Production-ready configuration
Test Coverage: 95% (265+ tests)
Code Quality: Type-checked with mypy
Lines of Code: ~15,000 (including UI)
๐บ๏ธ Roadmap
Completed
- โ Core composition engine
- โ CLI interface
- โ REST API (32 endpoints)
- โ Web UI (8 pages)
- โ Real-time monitoring
- โ Protocol translation
- โ Docker deployment
- โ Comprehensive documentation
Future Enhancements
- ๐ Plugin system for custom extensions
- ๐ GraphQL API support
- ๐ Advanced caching strategies
- ๐ Distributed deployment support
- ๐ Enhanced analytics
- ๐ CLI auto-completion
๐ค Contributing
Contributions are welcome! Please see our Contributing Guide for details.
# Fork and clone
git clone https://github.com/YOUR_USERNAME/mcp-compose.git
# Create feature branch
git checkout -b feature/amazing-feature
# Make changes and test
make test
# Commit and push
git commit -m "Add amazing feature"
git push origin feature/amazing-feature
# Create Pull Request
๐ License
BSD 3-Clause License - see LICENSE for details.
๐ Acknowledgments
- Built on FastMCP framework
- Inspired by the Model Context Protocol specification
- UI built with React, TypeScript, and Recharts
- Special thanks to all contributors
๐ง Support
- Documentation: Full documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Sponsor: Become a sponsor
Made with โค๏ธ by Datalayer composer = MCPServerComposer( composed_server_name="unified-data-server", conflict_resolution=ConflictResolution.PREFIX )
Compose from current directory's pyproject.toml
unified_server = composer.compose_from_pyproject()
Get detailed composition information
summary = composer.get_composition_summary() print(f"Created server with {summary['total_tools']} tools")
#### Advanced Configuration
```python
from pathlib import Path
from mcp_compose import MCPServerComposer, ConflictResolution
# Specify custom pyproject.toml location
composer = MCPServerComposer(
composed_server_name="my-server",
conflict_resolution=ConflictResolution.SUFFIX
)
# Compose with filtering
unified_server = composer.compose_from_pyproject(
pyproject_path=Path("custom/pyproject.toml"),
include_servers=["jupyter-mcp-server", "earthdata-mcp-server"],
exclude_servers=["deprecated-server"]
)
# Access composed tools and prompts
tools = composer.list_tools()
prompts = composer.list_prompts()
source_info = composer.get_source_info()
print(f"Tools: {', '.join(tools)}")
print(f"Sources: {', '.join(source_info.keys())}")
Discovery Only
from mcp_compose import MCPServerDiscovery
# Discover MCP servers without composing
discovery = MCPServerDiscovery()
servers = discovery.discover_from_pyproject("pyproject.toml")
for name, info in servers.items():
print(f"{name}: {len(info.tools)} tools, {len(info.prompts)} prompts")
Configuration
Conflict Resolution Strategies
When multiple servers provide tools or prompts with the same name, you can choose how to resolve conflicts:
- PREFIX (default): Add server name as prefix (
server1_tool_name) - SUFFIX: Add server name as suffix (
tool_name_server1) - OVERRIDE: Last server wins (overwrites previous)
- IGNORE: Skip conflicting items
- ERROR: Raise an error on conflicts
Example Conflict Resolution
# If two servers both have a "search" tool:
# PREFIX: jupyter_mcp_server_search, earthdata_mcp_server_search
# SUFFIX: search_jupyter_mcp_server, search_earthdata_mcp_server
# OVERRIDE: Only the last server's "search" tool is kept
Real-World Examples
Data Science Workflow
Create a unified MCP server combining Jupyter notebook capabilities with Earth science data access:
# pyproject.toml
[project]
dependencies = [
"jupyter-mcp-server>=1.0.0",
"earthdata-mcp-server>=0.1.0",
"weather-mcp-server>=2.0.0"
]
# Discover available tools
python -m mcp_compose discover
# Create unified server for data science workflow
python -m mcp_compose compose \
--name "data-science-server" \
--conflict-resolution prefix \
--output unified_server.py
This creates a server with tools like:
jupyter_create_notebook- Create analysis notebooksearthdata_search_datasets- Find Earth science dataweather_get_forecast- Access weather data- Combined prompts for data analysis workflows
Development Environment
Combine development tools and documentation servers:
from mcp_compose import MCPServerComposer, ConflictResolution
composer = MCPServerComposer(
composed_server_name="dev-environment",
conflict_resolution=ConflictResolution.PREFIX
)
# Compose development-focused servers
dev_server = composer.compose_from_pyproject(
include_servers=[
"code-review-mcp-server",
"documentation-mcp-server",
"testing-mcp-server"
]
)
# Access all development tools in one place
print("Available tools:", composer.list_tools())
Custom Integration
from mcp_compose import MCPServerComposer
from my_custom_server import MyMCPServer
# Create composer
composer = MCPServerComposer()
# Compose discovered servers
unified_server = composer.compose_from_pyproject()
# Add your custom server manually if needed
composer.add_server("custom", MyMCPServer())
# Get final composition summary
summary = composer.get_composition_summary()
print(f"Final server has {summary['total_tools']} tools from {summary['source_servers']} sources")
Project Structure
When using MCP Compose, structure your project like this:
my-project/
โโโ pyproject.toml # Define MCP server dependencies
โโโ src/
โ โโโ my_project/
โ โโโ __init__.py
โ โโโ main.py # Use composed server
โโโ composed_server.py # Generated unified server (optional)
โโโ README.md
Sample pyproject.toml
[project]
name = "my-data-project"
dependencies = [
"jupyter-mcp-server>=1.0.0",
"earthdata-mcp-server>=0.1.0",
"fastmcp>=1.2.0"
]
[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
"mcp-compose>=1.0.0"
]
Error Handling
The library provides comprehensive error handling:
from mcp_compose import MCPServerComposer, MCPComposerError, MCPDiscoveryError
try:
composer = MCPServerComposer()
server = composer.compose_from_pyproject()
except MCPDiscoveryError as e:
print(f"Discovery failed: {e}")
print(f"Search paths: {e.search_paths}")
except MCPComposerError as e:
print(f"Composition failed: {e}")
print(f"Server count: {e.server_count}")
Troubleshooting
Common Issues
- No MCP servers found: Ensure your dependencies include packages with "mcp" in the name
- Import errors: Check that MCP server packages are properly installed
- Naming conflicts: Use appropriate conflict resolution strategy
- Missing tools: Verify that server packages export an
appvariable
Debug Mode
# Enable verbose logging
python -m mcp_compose discover --verbose
# Check specific package
python -c "
from mcp_compose import MCPServerDiscovery
discovery = MCPServerDiscovery()
result = discovery._analyze_mcp_server('your-package-name')
print(result)
"
## API Reference
### MCPServerComposer
Main class for composing MCP servers:
```python
MCPServerComposer(
composed_server_name: str = "composed-mcp-server",
conflict_resolution: ConflictResolution = ConflictResolution.PREFIX
)
Methods:
compose_from_pyproject(pyproject_path, include_servers, exclude_servers)- Compose servers from dependenciesget_composition_summary()- Get summary of composition resultslist_tools()- List all available toolslist_prompts()- List all available promptsget_source_info()- Get mapping of tools/prompts to source servers
MCPServerDiscovery
Class for discovering MCP servers:
MCPServerDiscovery(mcp_server_patterns: List[str] = None)
Methods:
discover_from_pyproject(pyproject_path)- Discover servers from pyproject.tomlget_package_version(dependency_spec)- Extract version from dependency string
ConflictResolution
Enum for conflict resolution strategies:
PREFIX- Add server name as prefixSUFFIX- Add server name as suffixOVERRIDE- Last server winsIGNORE- Skip conflicting itemsERROR- Raise error on conflicts
Requirements
- Python 3.8+
- FastMCP >= 1.2.0
- TOML parsing support
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Ensure all tests pass (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
See CHANGELOG.md for version history and changes.
Support
- ๐ Documentation: Full API documentation and examples in this README
- ๐ Issues: Report bugs and request features on GitHub Issues
- ๐ฌ Discussions: Join the conversation in GitHub Discussions
Related Projects
- FastMCP - Python SDK for Model Context Protocol
- MCP Specification - Official MCP specification
- Jupyter MCP Server - MCP server for Jupyter functionality
- Earthdata MCP Server - MCP server for NASA Earthdata access
Made with โค๏ธ by the Datalayer team
- Earthdata MCP Server - MCP server for NASA Earthdata
Changelog
See CHANGELOG.md for a detailed history of changes.
Support
- GitHub Issues: Report bugs or request features
- Documentation: Full documentation
- Community: Join the discussion
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_compose-0.1.5-py3-none-any.whl.
File metadata
- Download URL: mcp_compose-0.1.5-py3-none-any.whl
- Upload date:
- Size: 677.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6fc670ab7a90dd51fddc6c40a09793aa36551d226f5e638601a8eb7dc52d4d0
|
|
| MD5 |
5e176d57cc12869873d6cb60995c4cab
|
|
| BLAKE2b-256 |
c34ded1b3eb71148fe13797a5bf237dc25e35fd9875df218d7a8a086bb3750cc
|