Aggregate MCP servers & apply middlewares; host & emit unified MCP servers out

πŸš€ MetaMCP (Aggregate MCP servers & apply middlewares; host & emit unified MCP servers out)

MetaMCP is a MCP proxy that lets you dynamically aggregate MCP servers into a unified MCP server, and apply middlewares. MetaMCP itself is a MCP server so it can be easily plugged into ANY MCP clients.

MetaMCP Diagram

πŸ“‹ Table of Contents

  • 🎯 Use Cases
  • πŸ“– Concepts
    • πŸ–₯️ MCP Server
    • 🏷️ MetaMCP Namespace
    • 🌐 MetaMCP Endpoint
    • βš™οΈ Middleware
    • πŸ” Inspector
  • πŸš€ Quick Start
    • 🐳 Run with Docker Compose (Recommended)
    • πŸ’» Local Development
  • πŸ”Œ MCP Protocol Compatibility
  • ❄️ Cold Start Problem and Custom Dockerfile
  • πŸ” Authentication
  • πŸ—οΈ Architecture
    • πŸ“Š Sequence Diagram
  • πŸ—ΊοΈ Roadmap
  • 🀝 Contributing
  • πŸ“„ License
  • πŸ™ Credits

🎯 Use Cases

  • πŸ”„ One-click server switching - Save and switch MCP server configs for Claude Desktop, Cursor, or custom agents
  • πŸ” Enhanced MCP inspector - Debug with saved server configurations
  • πŸ”— Unified server aggregation - Join multiple servers for simplified agent development
  • ⚑ Dynamic tool management - Quick toggles to enable/disable servers and tools
  • πŸ› οΈ Middleware support - Apply logging, error handling, and custom transformations
  • 🎯 Dynamic search rules - Apply search rules and return different toolsets for agent builders

Generally developers can use MetaMCP as infrastructure to host dynamically composed MCP servers through a unified endpoint, and build agents on top of it.

Quick demo video: https://youtu.be/Cf6jVd2saAs

MetaMCP Screenshot

πŸ“– Concepts

πŸ–₯️ MCP Server

A MCP server configuration that tells MetaMCP how to start a MCP server.

"HackerNews": {
  "type": "STDIO",
  "command": "uvx",
  "args": ["mcp-hn"]
}

🏷️ MetaMCP Namespace

  • Group one or more MCP servers into a namespace
  • Enable/disable MCP servers or at tool level
  • Apply middlewares to MCP requests and responses

🌐 MetaMCP Endpoint

  • Create endpoints and assign namespace to endpoints
  • Multiple MCP servers in the namespace will be aggregated and emitted as a MetaMCP endpoint
  • Choose auth level and strategy
  • Host through SSE or Streamable HTTP transports

βš™οΈ Middleware

  • Intercepts and transforms MCP requests and responses at namespace level
  • Built-in example: "Filter inactive tools" - optimizes tool context for LLMs
  • Future ideas: tool logging, error traces, validation, scanning

πŸ” Inspector

Similar to the official MCP inspector, but with saved server configs - MetaMCP automatically creates configurations so you can debug MetaMCP endpoints immediately.

πŸš€ Quick Start

🐳 Run with Docker Compose (Recommended)

Clone repo, prepare .env, and start with docker compose:

git clone https://github.com/metatool-ai/metamcp.git
cd metamcp
cp example.env .env
docker compose up --build -d

πŸ’» Local Development

Still recommend running postgres through docker for easy setup:

pnpm install
pnpm dev

πŸ”Œ MCP Protocol Compatibility

  • βœ… Tools, Resources, and Prompts supported
  • βœ… OAuth-enabled MCP servers tested for 03-26 version

If you have questions, feel free to leave GitHub issues or PRs.

❄️ Cold Start Problem and Custom Dockerfile

⚠️ Cold start issue for hosting stdio type MCP servers:

  • First run will be slow as package managers (uvx, npx) install dependencies
  • Happens again on docker restart

πŸ› οΈ Solution: Customize the Dockerfile to add dependencies or pre-install packages to reduce cold start time.

πŸ” Authentication

  • πŸ›‘οΈ Better Auth for frontend and backend (trpc procedures)
  • πŸͺ Session cookies enforce internal MCP proxy connections
  • πŸ”‘ API key auth for external access via Authorization: Bearer <api-key> header
  • Note though: the repo is not designed for multi-tenancy and each org should self-host an instance for org wide. E.g., MCP server has no user_id association, so every account have access to every MCP server configs hosted on the instance.

πŸ—οΈ Architecture

  • Frontend: Next.js
  • Backend: Express.js with tRPC, hosting MCPs through TS SDK and internal proxy
  • Auth: Better Auth
  • Structure: Standalone monorepo with Turborepo and Docker publishing

πŸ“Š Sequence Diagram

Note: Prompts and resources follow similar patterns to tools.

sequenceDiagram
    participant MCPClient as MCP Client (e.g., Claude Desktop)
    participant MetaMCP as MetaMCP Server
    participant MCPServers as Installed MCP Servers

    MCPClient ->> MetaMCP: Request list tools

    loop For each listed MCP Server
        MetaMCP ->> MCPServers: Request list_tools
        MCPServers ->> MetaMCP: Return list of tools
    end

    MetaMCP ->> MetaMCP: Aggregate tool lists & apply middleware
    MetaMCP ->> MCPClient: Return aggregated list of tools

    MCPClient ->> MetaMCP: Call tool
    MetaMCP ->> MCPServers: call_tool to target MCP Server
    MCPServers ->> MetaMCP: Return tool response
    MetaMCP ->> MCPClient: Return tool response

πŸ—ΊοΈ Roadmap

Potential next steps:

  • πŸ”Œ Headless Admin API access
  • πŸ” Dynamically apply search rules on MetaMCP endpoints
  • πŸ› οΈ More middlewares
  • πŸ’¬ Chat/Agent Playground
  • πŸ§ͺ Testing & Evaluation for MCP tool selection optimization
  • ⚑ Dynamically generate MCP servers

🀝 Contributing

We welcome contributions! See details at CONTRIBUTING.md

πŸ“„ License

MIT

Would appreciate if you mentioned with back links if your projects use the code.

πŸ™ Credits

Some code inspired by:

MCP Server Β· Populars

MCP Server Β· New