MCP HubMCP Hub
adamwattis

mcp-proxy-server

by: adamwattis

An MCP proxy server that aggregates and serves multiple MCP resource servers through a single interface

75created 04/12/2024
Visit
proxy
aggregator

📌Overview

Purpose: To serve as a central hub that aggregates multiple MCP resource servers and provides a unified interface for resource management and tool aggregation.

Overview: The MCP Proxy Server efficiently connects and manages multiple MCP resource servers, allowing users to access their combined capabilities through a single interface. It handles routing of requests and aggregates responses from various backend servers, streamlining interactions with multiple sources.

Key Features:

  • Resource Management: Discovers and connects to multiple MCP resource servers, aggregates resources, and maintains consistent URI schemes to facilitate effective routing and resolution of requests.

  • Tool Aggregation: Exposes tools from all connected servers and routes requests correctly, ensuring seamless interaction while managing tool states and responses.

  • Prompt Handling: Aggregates prompts from connected servers and routes requests to appropriate backends, enabling the handling of multi-server prompt responses efficiently.


MCP Proxy Server

An MCP proxy server that aggregates and serves multiple MCP resource servers through a single interface. This server acts as a central hub that:

  • Connects to and manages multiple MCP resource servers
  • Exposes their combined capabilities through a unified interface
  • Handles routing of requests to appropriate backend servers
  • Aggregates responses from multiple sources

Features

Resource Management

  • Discover and connect to multiple MCP resource servers
  • Aggregate resources from all connected servers
  • Maintain consistent URI schemes across servers
  • Handle resource routing and resolution

Tool Aggregation

  • Expose tools from all connected servers
  • Route tool calls to appropriate backend servers
  • Maintain tool state and handle responses

Prompt Handling

  • Aggregate prompts from all connected servers
  • Route prompt requests to appropriate backends
  • Handle multi-server prompt responses

Configuration

The server requires a JSON configuration file specifying the MCP servers to connect to. Copy the example config and modify it for your needs:

cp config.example.json config.json

Example config structure:

{
  "servers": [
    {
      "name": "Server 1",
      "transport": {
        "command": "/path/to/server1/build/index.js"
      }
    },
    {
      "name": "Server 2",
      "transport": {
        "command": "server2-command",
        "args": ["--option1", "value1"],
        "env": ["SECRET_API_KEY"]
      }
    },
    {
      "name": "Example Server 3",
      "transport": {
        "type": "sse",
        "url": "http://localhost:8080/sse"
      }
    }
  ]
}

Provide the config file when running the server:

MCP_CONFIG_PATH=./config.json mcp-proxy-server

Development

Install dependencies:

npm install

Build the server:

npm run build

For development with auto-rebuild:

npm run watch

For development with continuous run:

# Stdio
npm run dev
# SSE
npm run dev:sse

Installation

To use with Claude Desktop, add the server config:

  • On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • On Windows: %APPDATA%/Claude/claude_desktop_config.json

Example configuration:

{
  "mcpServers": {
    "mcp-proxy": {
      "command": "/path/to/mcp-proxy-server/build/index.js",
      "env": {
        "MCP_CONFIG_PATH": "/absolute/path/to/your/config.json",
        "KEEP_SERVER_OPEN": "1"
      }
    }
  }
}
  • KEEP_SERVER_OPEN keeps the SSE running even if a client disconnects—useful when multiple clients connect to the MCP proxy.

Debugging

Since MCP servers communicate over stdio, debugging can be challenging. It is recommended to use the MCP Inspector, available as a package script:

npm run inspector

The Inspector will provide a URL to access debugging tools in your browser.