Mcp Gateway

io.github.rupinder2由 GitHub 账号 rupinder2 发布v0.1.1更新于 Oct 24, 2026

Aggregates tools from multiple MCP servers with unified BM25/regex search and deferred loading.

已验证STDIO仅桌面开发者工具AI 与机器学习

概览

AI 生成的概览

一个本地 MCP 网关,连接多个下游 MCP 服务器,汇总其工具并提供统一搜索与调用入口。

可以做什么
  • 用 BM25 自然语言排序或正则表达式在所有已注册下游服务器的工具中搜索
  • 发现并索引某个已注册下游服务器提供的工具
  • 按命名空间(server_name__tool_name)调用下游工具并传入参数,可覆盖其认证头
  • 通过 JSON 配置文件注册下游服务器,支持 stdio 或 HTTP 传输
  • 将工具定义缓存在内存或 Redis 中,减少上下文占用
适用场景
当你运行多个 MCP 服务器、希望只接一个入口而不必逐个添加时适用;也适合工具总量过大、会挤占助手上下文窗口的场景。需要延迟加载工具并在多个服务器之上建立统一可搜索索引时尤为合适。
运行要求
以本地 Python 包运行(pip install mcp-orchestrator),默认 stdio,也可通过 ORCHESTRATOR_TRANSPORT 与 ORCHESTRATOR_PORT 走 HTTP。需要 server_config.json 列出下游服务器,路径由 SERVER_CONFIG_PATH 指定。STORAGE_BACKEND 选择 memory 或 redis,仅 redis 后端需要 REDIS_URL。下游服务器可能各自需要令牌或启动命令。
安装前请注意
配置文件可保存下游服务器的静态认证头(如 bearer 令牌),不要提交到版本库。助手可调用所有已注册下游服务器的任意工具,包括写入、发送或删除数据的工具,且 call_remote_tool 允许覆盖认证头。HTTP 传输默认监听 0.0.0.0 并启用 CORS,可能使网关暴露在 localhost 之外。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp Gateway,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

MCP Orchestrator

[PyPI Version] [Python Version] [License: MIT] [Tests] [Contributions Welcome]

A central hub that connects to multiple downstream MCP servers, aggregates their tools, and provides unified access with powerful tool search capabilities.

Built around deferred tool loading — search across all your servers without blowing Claude's context window.

Features

  • Config-based Server Registration: Add downstream MCP servers via JSON config file
  • Tool Namespacing: Automatic server_name__tool_name format
  • Tool Search: Unified BM25/regex search with deferred loading support
  • Flexible Authentication: Static saved headers or token forwarding
  • Multiple Transports: stdio or HTTP
  • Tool Definition Caching: Cached definitions, raw result passthrough
  • Storage Backends: In-memory (development) or Redis (production)

Quick Start

Installation

bash
pip install mcp-orchestrator

Running the MCP Server

bash
# Run as stdio MCP server (for Claude Desktop, Cursor, etc.)mcp-orchestrator
# Or run with Python directlypython -m mcp_orchestrator.main

HTTP Transport:

bash
ORCHESTRATOR_TRANSPORT=http ORCHESTRATOR_PORT=8080 python -m mcp_orchestrator.main

This starts the server on http://localhost:8080/mcp with CORS enabled.

Configuring Servers

Add downstream MCP servers in server_config.json:

json
{  "servers": [    {      "name": "my-server",      "url": "http://localhost:8080/mcp",      "transport": "http",      "auth_type": "static",      "auth_headers": {        "Authorization": "Bearer my-token"      }    },    {      "name": "my-stdio-server",      "url": "server.py",      "transport": "stdio",      "command": "uv",      "args": ["run", "python", "server.py"]    }  ]}

Searching for Tools

The orchestrator provides unified tool search (BM25 by default, regex optional):

python
# BM25 search (default - natural language)results = await mcp_client.call_tool("tool_search", {    "query": "get weather information",    "max_results": 3})
# Regex search (set use_regex=true)results = await mcp_client.call_tool("tool_search", {    "query": "weather|forecast",    "use_regex": true,    "max_results": 3})

Architecture

┌─────────────────────────────────────────────────────┐│                  MCP Orchestrator                    ││                                                      ││  ┌──────────────────────────────────────────────┐   ││  │              FastMCP Server                   │   ││  │  ┌─────────────┐  ┌──────────────────┐   │   ││  │  │ tool_search │  │ call_remote_tool  │   │   ││  │  └─────────────┘  └──────────────────┘   │   ││  └──────────────────────────────────────────────┘   ││                                                      ││  ┌──────────┐  ┌──────────┐  ┌──────────────┐      ││  │  Server  │  │   Tool   │  │   Storage    │      ││  │ Registry │  │  Search  │  │(Memory/Redis)│      ││  └──────────┘  └──────────┘  └──────────────┘      │└─────────────────────────────────────────────────────┘                           │        ┌───────────────────┼───────────────────┐        ▼                   ▼                   ▼   ┌─────────┐        ┌─────────┐        ┌─────────┐   │ MCP Svr │        │ MCP Svr │        │ MCP Svr │   │   #1    │        │   #2    │        │   #N    │   └─────────┘        └─────────┘        └─────────┘

Configuration

Environment Variables

VariableDefaultDescription
STORAGE_BACKENDmemoryStorage backend (memory or redis)
REDIS_URLredis://localhost:6379/0Redis connection URL
MCP_ORCHESTRATOR_TOOL_CACHE_TTL300Tool schema cache TTL in seconds
MCP_ORCHESTRATOR_DEFAULT_CONNECTION_MODEstatelessDefault connection mode
MCP_ORCHESTRATOR_CONNECTION_TIMEOUT30.0Connection timeout in seconds
MCP_ORCHESTRATOR_MAX_RETRIES3Maximum retry attempts
ORCHESTRATOR_TRANSPORTstdioMCP transport (stdio or http)
ORCHESTRATOR_PORT8080Port for HTTP transport
ORCHESTRATOR_HOST0.0.0.0Host for HTTP transport
ORCHESTRATOR_LOG_LEVELINFOLogging level
SERVER_CONFIG_PATHserver_config.jsonPath to server configuration file

Claude Desktop Integration

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

json
{  "mcpServers": {    "mcp-orchestrator": {      "command": "mcp-orchestrator",      "env": {        "STORAGE_BACKEND": "memory",        "ORCHESTRATOR_LOG_LEVEL": "INFO"      }    }  }}

MCP Tools

tool_search

Search for tools using BM25 relevance ranking or regex pattern matching.

python
@mcp.tool()async def tool_search(    query: str,    max_results: int = 3,    use_regex: bool = False,) -> dict:    """Search for tools using BM25 or regex.
    By default uses BM25 natural language search. Set use_regex=True    to search using Python regex patterns instead.    """

discover_tools

Discover tools from a registered downstream server.

python
@mcp.tool()async def discover_tools(    server_name: str,) -> dict:    """Discover tools from a registered server and index them for search.
    Returns the list of discovered tools with their schemas.    """

call_remote_tool

Call a tool directly on a downstream MCP server.

python
@mcp.tool()async def call_remote_tool(    tool_name: str,    arguments: Optional[dict] = None,    auth_header: Optional[str] = None,) -> Any:    """Call a tool on a downstream server.
    Args:        tool_name: Namespaced tool name (server_name__tool_name)        arguments: Tool arguments        auth_header: Optional auth header to override server's configured auth    """

Tool Search Results

The search tools return results in the format expected by Claude's tool search system:

json
{  "success": true,  "tool_references": [    {      "type": "tool_reference",      "tool_name": "server_name__tool_name"    }  ],  "total_matches": 5,  "query": "weather"}

Testing

Run the test suite:

bash
uv run pytest

Run with coverage:

bash
uv run pytest --cov=mcp_orchestrator

Project Structure

mcp-orchestrator/├── src/mcp_orchestrator/│   ├── __init__.py│   ├── main.py              # Entry point│   ├── models.py            # Pydantic models│   ├── mcp_server.py        # FastMCP server│   ├── config_loader.py     # Config file loader│   ├── server/│   │   └── registry.py      # Server registry│   ├── tools/│   │   ├── router.py       # Tool router│   │   └── search.py       # Tool search service│   └── storage/│       ├── base.py          # Storage interface│       ├── memory.py        # In-memory backend│       └── redis.py         # Redis backend├── tests/│   ├── test_registry.py│   ├── test_search.py│   ├── test_storage.py│   ├── test_models.py│   └── test_integration.py├── server_config.json       # Pre-configured downstream servers├── pyproject.toml├── README.md└── .env                    # Environment variables (not committed)

License

MIT License

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

来源:README.md,提交 b44912b

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分