AM

adamwattis/mcp-proxy-server

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

202 stars 44 forks 质量 68 趋势 17MIT

adamwattis/mcp-proxy-server 是从 https://github.com/adamwattis/mcp-proxy-server. 导入的 MCP 服务器候选服务器。

概览

adamwattis/mcp-proxy-server 是从 https://github.com/adamwattis/mcp-proxy-server. 导入的 MCP 服务器候选服务器。

概述(AI 翻译)

一个MCP代理服务器,通过单一接口聚合并服务多个MCP资源服务器。该服务器作为一个中央枢纽,能够:

  • 连接和管理多个MCP资源服务器
  • 通过统一接口公开其综合能力
  • 处理请求路由到相应后端服务器
  • 来自多个来源的汇总响应

特色

资源管理

  • 发现并连接多个MCP资源服务器
  • 汇总所有连接服务器的资源
  • 在服务器间保持一致的URI方案
  • 处理资源路由和解析

工具聚合

  • 从所有连接服务器中暴露工具
  • 将工具调用路由到相应的后端服务器
  • 维护工具状态并处理响应

提示处理

  • 来自所有连接服务器的汇总提示
  • 将提示请求路由到相应的后端
  • 处理多服务器即时响应

配置

服务器需要一个 JSON 配置文件,指定要连接的 MCP 服务器。复制示例配置并根据需求进行修改:

示例配置结构:

运行服务器时必须提供配置文件:

发展

本页由 AI 翻译,技术细节请以原文为准。

README

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 can:

  • Connect to and manage multiple MCP resource servers
  • Expose their combined capabilities through a unified interface
  • Handle routing of requests to appropriate backend servers
  • Aggregate 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 that specifies 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"
      }
    }
  ]
}

The config file must be provided 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

{
  "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 will keep the SSE running even if a client disconnects. Useful when multiple clients connects to the MCP proxy.

Debugging

Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:

npm run inspector

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

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "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" } } } }