Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hudy93/mcp-gateway

Repository files navigation

MCP Gateway

A gateway service for routing user queries to appropriate domain-specific Model Context Protocol (MCP) servers.

Introduction

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.

Architecture

MCP Gateway Architecture Overview

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)

Features

  • 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

Getting Started

Prerequisites

  • Java 17 or higher
  • Gradle 7.6 or higher
  • Spring Boot 3.1 or higher

Running Locally

  1. Clone the repository:

    git clone https://github.com/your-org/mcp-gateway.git
    cd mcp-gateway
  2. Build the project:

    ./gradlew build
  3. 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.

API Endpoints

  • POST /api/v1/query - Submit a query to the most appropriate MCP server
  • POST /api/v1/query/multi - Submit a query to multiple relevant MCP servers
  • POST /api/v1/query/evaluated - Submit a query and get evaluated results
  • GET /api/v1/servers - List all registered MCP servers
  • POST /api/v1/servers - Register a new MCP server
  • GET /api/v1/servers/{serverId} - Get details of a specific MCP server
  • PUT /api/v1/servers/{serverId} - Update a registered MCP server
  • DELETE /api/v1/servers/{serverId} - Deregister an MCP server

Development

For detailed implementation instructions, see dev-instruction.md.

Project Structure

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/

Deployment

The MCP Gateway is designed to be deployed as a containerized application. See the deployment section in the implementation guide for detailed deployment instructions.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages