Labsco
rupinder2 logo

MCP Orchestrator

β˜… 2

from rupinder2

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

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

MCP Orchestrator

<!-- mcp-name: io.github.rupinder2/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)

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    β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

MCP Tools

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

@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.

@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.

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

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

Testing

Run the test suite:

uv run pytest

Run with coverage:

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)