
A routing proxy for agent traffic to Model Context Protocol (MCP) servers. This gateway enables seamless integration between AI agents and MCP servers, providing intelligent request routing, session...
概览
A routing proxy for agent traffic to Model Context Protocol (MCP) servers. This gateway enables seamless integration between AI agents and MCP servers, providing intelligent request routing, session management, and usage analytics. There are some very interesting downstream applications of a more involved version of this but I wanted to just release a very lightweight and extendable version :) : Single Python file deployment with minimal dependencies : Easy to extend, modify, and customize for your specific needs : Full control over your infrastructure and data - : Routes requests to appropriate MCP servers using OpenAI-powered tool matching - : Persistent session handling for stateful interactions - : Queue-based request processing with Redis backend - : RESTful interface for easy integration with any agent runtime - : Built-in metrics and monitoring capabilities - : Easy to add new MCP servers and custom routing logic The MCP Gateway uses a simple, modular architecture designed...
README
以下为原文 README 节选,完整内容请查看原文。
MCP Gateway
A lightweight, modular, and self-hostable routing proxy for agent traffic to Model Context Protocol (MCP) servers. This gateway enables seamless integration between AI agents and MCP servers, providing intelligent request routing, session management, and usage analytics. There are some very interesting downstream applications of a more involved version of this but I wanted to just release a very lightweight and extendable version :)
Self-Host Ready: Single Python file deployment with minimal dependencies
Highly Modular: Easy to extend, modify, and customize for your specific needs
Zero Lock-in: Full control over your infrastructure and data
Features
- Intelligent Routing: Routes requests to appropriate MCP servers using OpenAI-powered tool matching
- Session Management: Persistent session handling for stateful interactions
- Redis Integration: Queue-based request processing with Redis backend
- HTTP API: RESTful interface for easy integration with any agent runtime
- Usage Analytics: Built-in metrics and monitoring capabilities
- Extensible: Easy to add new MCP servers and custom routing logic
Architecture
The MCP Gateway uses a simple, modular architecture designed for easy self-hosting and customization:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ AI Agents │ │ MCP Gateway │ │ Any Tool │
│ │ │ │ │ │
│ • Claude Code │◄──►│ • Smart Routing │◄──►│ • MCP │
│ • Custom Agents │ │ • Session Mgmt │ │ • Other Agents │
│ • LLM Apps │ │ • HTTP/MCP APIs │ │ • (any endpoint)│
│ │ │ │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Two Integration Paths
-
HTTP API Mode: Direct REST API calls to the gateway
- Perfect for web apps, microservices, and custom integrations
- Simple HTTP POST/GET requests
- Session management via headers
-
MCP Server Mode: Gateway acts as an MCP server itself
- Use
mcp_remote.pyto expose gateway as an MCP server - Native MCP protocol support
- Seamless integration with MCP-compatible agents
- Use
Core Components
gateway.py: Main routing engine with intelligent tool matching (currently supports all MCPs, can be extended to generic tools)session.py: Stateful session management for multi-turn conversationsmcp_remote.py: MCP server wrapper for native protocol supportmcp_servers/: Example server implementations you can extendservers.txt: List of any MCPs you want to support
🚀 Quick Start (30 seconds)
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →