A gateway service for routing user queries to appropriate domain-specific Model Context Protocol (MCP) servers.
The MCP Gateway acts as a central hub that receives user queries, determines which domain-specific MCP server(s) to forward the query to, and returns the most accurate response. It implements the Model Context Protocol for standardized communication with LLM applications.
The MCP Gateway is composed of several microservices:
- API Gateway: Receives and validates user queries
- Context Router: Analyzes queries and routes them to appropriate MCP servers
- Server Registry: Maintains a registry of available MCP servers and their capabilities
- MCP Communicator: Handles communication with MCP servers using the MCP protocol
- Health Monitor: Monitors the health and status of registered MCP servers
- Response Evaluator: Evaluates and ranks responses from multiple MCP servers (optional)
- Dynamic routing of queries based on content analysis
- Registry of MCP servers with capabilities and domain information
- Health monitoring of connected MCP servers
- Response evaluation and ranking
- Circuit breaking and fallback mechanisms for resilience
- RESTful API for integration
- Java 17 or higher
- Gradle 7.6 or higher
- Spring Boot 3.1 or higher
-
Clone the repository:
git clone https://github.com/your-org/mcp-gateway.git cd mcp-gateway -
Build the project:
./gradlew build
-
Run the application:
./gradlew bootRun --args='--spring.profiles.active=dev'
The application will start on http://localhost:8080 with sample MCP servers pre-configured for testing.
POST /api/v1/query- Submit a query to the most appropriate MCP serverPOST /api/v1/query/multi- Submit a query to multiple relevant MCP serversPOST /api/v1/query/evaluated- Submit a query and get evaluated resultsGET /api/v1/servers- List all registered MCP serversPOST /api/v1/servers- Register a new MCP serverGET /api/v1/servers/{serverId}- Get details of a specific MCP serverPUT /api/v1/servers/{serverId}- Update a registered MCP serverDELETE /api/v1/servers/{serverId}- Deregister an MCP server
For detailed implementation instructions, see dev-instruction.md.
mcp-gateway/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── cplace/
│ │ │ └── mcpgateway/
│ │ │ ├── api/ # API Gateway
│ │ │ ├── communicator/ # MCP Communicator
│ │ │ ├── config/ # Configuration
│ │ │ ├── evaluator/ # Response Evaluator
│ │ │ ├── health/ # Health Monitor
│ │ │ ├── model/ # Data Models
│ │ │ ├── registry/ # Server Registry
│ │ │ └── router/ # Context Router
│ │ └── resources/
│ └── test/
└── docs/
The MCP Gateway is designed to be deployed as a containerized application. See the deployment section in the implementation guide for detailed deployment instructions.
This project is licensed under the MIT License - see the LICENSE file for details.