MCP Aggregator Server
Provides a unified MCP interface that proxies requests to multiple backend servers including memory/knowledge graph and vector database services. Enables seamless access to distributed MCP tools through a single endpoint with automatic routing, health monitoring, and retry logic.
README
MCP Aggregator Server
Unified MCP interface that proxies requests to multiple backend MCP servers.
Architecture
┌─────────────────────────────────────────────────────────────┐
│ MCP Client │
│ (Claude, IDE, etc.) │
└────────────────────┬────────────────────────────────────────┘
│
│ Connect to single endpoint
▼
┌─────────────────────────────────────────────────────────────┐
│ Aggregator MCP Server (Port 8003) │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Unified MCP Interface │ │
│ │ - 19 tools total (2 health + 10 memory + 7 vector) │ │
│ │ - Handles routing internally │ │
│ │ - Single /mcp/sse & /mcp/messages endpoint │ │
│ └──────────────────────────────────────────────────────┘ │
└────────┬──────────────────────────────────────────────────┬──┘
│ │
│ HTTP Proxy │ HTTP Proxy
▼ ▼
┌──────────────────────┐ ┌──────────────────────┐
│ ZepAI Memory Server │ │ LTM Vector Server │
│ (Port 8002) │ │ (Port 8000) │
│ │ │ │
│ - Knowledge Graph │ │ - Vector Database │
│ - Conversation Memory│ │ - Code Indexing │
│ - 10 tools │ │ - 7 tools │
└──────────────────────┘ └──────────────────────┘
Features
- Unified Interface: Single MCP endpoint for all connected servers
- Transparent Proxying: Automatically routes requests to appropriate backend servers
- Health Monitoring: Built-in health checks for all connected servers
- Retry Logic: Automatic retry with exponential backoff for failed requests
- Error Handling: Comprehensive error handling and logging
- Extensible: Easy to add new backend servers
Installation
- Install dependencies:
pip install -r requirements.txt
- Configure environment (edit
.env):
# Aggregator Server
AGGREGATOR_HOST=0.0.0.0
AGGREGATOR_PORT=8003
# Memory Server (FastMCP Server)
MEMORY_SERVER_URL=http://localhost:8002
MEMORY_SERVER_TIMEOUT=30
# Graph Server (for future use)
GRAPH_SERVER_URL=http://localhost:8000
GRAPH_SERVER_TIMEOUT=30
Running
Start all servers in order:
Terminal 1 - LTM Vector Server (Port 8000):
cd LTM
python mcp_server/server_streamable_http.py
Terminal 2 - ZepAI FastMCP Server (Port 8002):
cd ZepAI/fastmcp_server
python server_http.py
Note: This automatically loads the Memory Layer and exposes both FastAPI + MCP on port 8002
Terminal 3 - MCP Aggregator (Port 8003):
cd mcp-aggregator
python aggregator_server.py
See START_SERVERS.md for detailed startup guide.
Available Tools
Health & Status
health_check()- Check health of all connected serversget_server_info()- Get information about connected servers
Memory Server Tools (Port 8002)
Search
memory_search(query, project_id, limit, use_llm_classification)- Search knowledge graphmemory_search_code(query, project_id, limit)- Search code memories
Ingest
memory_ingest_text(text, project_id, metadata)- Ingest plain textmemory_ingest_code(code, language, project_id, metadata)- Ingest codememory_ingest_json(data, project_id, metadata)- Ingest JSON datamemory_ingest_conversation(conversation, project_id)- Ingest conversation
Admin
memory_get_stats(project_id)- Get project statisticsmemory_get_cache_stats()- Get cache statistics
LTM Vector Server Tools (Port 8000)
Repository Processing
ltm_process_repo(repo_path)- Process repository for vector indexing
Vector Search
ltm_query_vector(query, top_k)- Query vector database for semantic code searchltm_search_file(filepath)- Search for specific file in vector database
File Management
ltm_add_file(filepath)- Add file to vector databaseltm_delete_by_filepath(filepath)- Delete file from vector databaseltm_delete_by_uuids(uuids)- Delete vectors by UUIDs
Code Analysis
ltm_chunk_file(file_path)- Chunk file using AST-based chunking
Testing
1. Check Server Health
curl http://localhost:8003/mcp/sse
2. Access OpenAPI Docs
http://localhost:8003/docs
3. Test a Tool via MCP
# Using MCP client
mcp-client http://localhost:8003/mcp health_check
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
AGGREGATOR_HOST |
0.0.0.0 |
Aggregator server host |
AGGREGATOR_PORT |
8003 |
Aggregator server port |
MEMORY_SERVER_URL |
http://localhost:8002 |
Memory server URL |
MEMORY_SERVER_TIMEOUT |
30 |
Memory server timeout (seconds) |
GRAPH_SERVER_URL |
http://localhost:8000 |
Graph server URL |
GRAPH_SERVER_TIMEOUT |
30 |
Graph server timeout (seconds) |
LOG_LEVEL |
INFO |
Logging level |
MAX_RETRIES |
3 |
Max retries for failed requests |
RETRY_DELAY |
1 |
Delay between retries (seconds) |
HEALTH_CHECK_INTERVAL |
30 |
Health check interval (seconds) |
Adding New Backend Servers
To add a new backend server (e.g., Graph Server):
- Update
config.py:
GRAPH_SERVER_URL = os.getenv("GRAPH_SERVER_URL", "http://localhost:8000")
GRAPH_SERVER_TIMEOUT = int(os.getenv("GRAPH_SERVER_TIMEOUT", "30"))
- Update
mcp_client.py:
class AggregatorClients:
def __init__(self):
# ... existing clients ...
self.graph_client = MCPServerClient(
"Graph Server",
config.GRAPH_SERVER_URL,
config.GRAPH_SERVER_TIMEOUT
)
- Add tools in
aggregator_server.py:
@mcp.tool()
async def graph_query(cypher: str) -> Dict[str, Any]:
"""Query Neo4j graph database"""
clients = await get_clients()
return await clients.graph_client.proxy_request(
"POST",
"/query",
json_data={"cypher": cypher},
retries=config.MAX_RETRIES
)
Troubleshooting
Connection Refused
- Ensure all backend servers are running
- Check URLs in
.envfile - Verify ports are not blocked by firewall
Timeout Errors
- Increase
MEMORY_SERVER_TIMEOUTorGRAPH_SERVER_TIMEOUTin.env - Check backend server performance
- Verify network connectivity
Health Check Failing
- Run
health_check()tool to diagnose - Check backend server logs
- Verify backend servers are responding
Development
Project Structure
mcp_aggregator/
├── aggregator_server.py # Main MCP server
├── config.py # Configuration management
├── mcp_client.py # HTTP clients for backend servers
├── requirements.txt # Python dependencies
├── .env # Environment variables
├── __init__.py # Package initialization
└── README.md # This file
Adding Logging
import logging
logger = logging.getLogger(__name__)
logger.info("Message")
logger.error("Error")
Future Enhancements
- [ ] Add Graph/Vector DB server integration
- [ ] Implement caching layer
- [ ] Add request rate limiting
- [ ] Implement server load balancing
- [ ] Add metrics/monitoring
- [ ] Support for server discovery
- [ ] WebSocket support for real-time updates
License
Same as parent project (Innocody)
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。