Skip to main content
Glama

🌐 mcp-mesh

The Dynamic Model Context Protocol Gateway & Lazy Tool Router
Aggregate 50+ upstream MCP servers, eliminate tool schema context bloat, and slash Turn-0 token consumption by 85–95% with zero external dependencies.

Official Portal Release CI: Test Suite PyPI version License: MIT Python 3.10+ Architecture: Zero Dependencies Protocol: MCP


💡 Why mcp-mesh?

The Model Context Protocol (MCP) is revolutionizing how LLMs interface with databases, code repositories, and external APIs. However, as developers connect agents to multiple MCP servers (GitHub, Postgres, Slack, Memory, Filesystem, AWS), a severe bottleneck emerges:

  1. Turn-0 Token Bloat: Connecting to 10 MCP servers injects 50 to 100+ full JSON schemas into the system prompt before the user types a single word. This burns 15,000 to 40,000 tokens per request.

  2. Context Window Degradation ("Lost in the Middle"): Flooding the prompt with hundreds of parameter definitions degrades LLM attention, causing tool hallucinations, invalid parameter formatting, and dropped instructions.

  3. Subprocess Hell: Managing dozens of discrete child processes across Cursor, Claude Desktop, and terminal agents leads to resource leaks and configuration fragility.

mcp-mesh solves this by acting as a single, transparent MCP gateway. Instead of exposing all 100 downstream schemas statically, it indexes your tools and exposes lightweight meta-tools (mesh_search_tools, mesh_describe_tool, mesh_invoke_tool).

Schemas are loaded lazily on demand. The result? Turn-0 context overhead drops from 25,000+ tokens to ~380 tokens—an immediate ~90% cost and latency reduction.


Related MCP server: MCP Gateway

✨ Features

  • 🚀 Zero External Dependencies: Engineered purely with Python 3.10+ standard library (json, http.server, subprocess, argparse, sys, dataclasses). Runs instantly anywhere without pip install friction.

  • 🩺 mcp-mesh doctor: Built-in environment & health diagnostics engine inspecting host runtimes (node, npx, uv, git, docker), configuration syntax, and downstream binary availability with latency probes.

  • 🌐 Server-Sent Events (SSE) & HTTP Transport: Run mcp-mesh sse as a shared team gateway daemon or Docker container for remote agents and cloud IDEs.

  • ⚡ Dynamic LRU Hot-Tier Schema Cache: In-memory cache keeps frequently-accessed tool schemas primed for instant multi-turn retrieval with zero lookup overhead.

  • 🔍 Semantic Keyword Tool Indexer: Sub-millisecond inverted index with BM25-style keyword and parameter matching across all aggregated upstream servers.

  • ⚡ Lazy Schema Loading: Exposes ultra-compact tool signatures (15–30 tokens) during discovery, loading full JSON schemas only when explicitly inspected or invoked.

  • 🔄 Transparent Stdio Multiplexing: Connects to your MCP client (Claude Desktop, Cursor, Antigravity, Cline) as a single standard stdio server while supervising downstream child processes.

  • 🛡️ Direct Invocation Fallback: Automatically resolves direct tool invocations (e.g. query_readonly or postgres::query_readonly) even if the agent bypasses the meta-tool wrapper.

  • 📊 Built-in Token Economy Meter: CLI diagnostic tools to inspect aggregated servers, measure Turn-0 token footprints, and verify net token savings.


🏛️ Architecture

 ┌────────────────────────────────────────────────────────┐
 │                    AI Client / IDE                     │
 │          (Claude Desktop, Cursor, Antigravity)         │
 └───────────────────────────┬────────────────────────────┘
                             │ stdio (JSON-RPC 2.0)
                             │ Only 3-4 Meta-Tools Exposed (~380 tokens)
                             ▼
 ┌────────────────────────────────────────────────────────┐
 │                   mcp-mesh Gateway                     │
 │  ┌──────────────────────────────────────────────────┐  │
 │  │      JSON-RPC 2.0 Parser & Stdio Transport       │  │
 │  └────────────────────────┬─────────────────────────┘  │
 │                           ▼                            │
 │  ┌──────────────────────────────────────────────────┐  │
 │  │        Tool Indexer & Token Economy Meter        │  │
 │  │      (BM25 Scoring, Signatures, Token Stats)     │  │
 │  └────────────────────────┬─────────────────────────┘  │
 │                           ▼                            │
 │  ┌──────────────────────────────────────────────────┐  │
 │  │    Process Multiplexer & Upstream Stdio Router   │  │
 │  └────────────────────────┬─────────────────────────┘  │
 └───────────────────────────┼────────────────────────────┘
                             │
         ┌───────────────────┼───────────────────┐
         ▼ stdio             ▼ stdio             ▼ stdio
 ┌───────────────┐   ┌───────────────┐   ┌───────────────┐
 │ GitHub MCP    │   │ Postgres MCP  │   │ Filesystem    │
 │ (35+ tools)   │   │ (15+ tools)   │   │ (12+ tools)   │
 └───────────────┘   └───────────────┘   └───────────────┘

⚡ Quick Start (5 Minutes)

Option A: Install from PyPI or Run with UV (Zero Install)

# Direct install from PyPI
pip install mcp-mesh

# Or execute instantly with zero installation via uvx:
uvx mcp-mesh demo

Option B: Clone & Run from Source (Zero External Dependencies)

git clone https://github.com/VanSchulist/mcp-mesh.git
cd mcp-mesh

# Run the interactive demo and token savings meter
python main.py demo

You will see the live economy report:

=================================================================
  mcp-mesh: Dynamic MCP Gateway & Lazy Tool Router (v1.1.0)
  Engineered by Van Schulist (@VanSchulist / Existential Cloud)
=================================================================

[+] AGGREGATION & TOKEN ECONOMY REPORT:
  Connected Servers  : 5
  Server IDs         : aws, filesystem, github, postgres, slack
  Total Tools        : 12
-----------------------------------------------------------------
  Raw Schema Tokens  : 2317 tokens (Turn-0 baseline)
  mcp-mesh Overhead  : 380 tokens (Meta-tool signatures)
  Net Tokens Saved   : 1937 tokens
  Efficiency Gain    : 83.6% token reduction!
=================================================================

🛠️ Configuration & Client Setup

Claude Desktop / Cursor / Antigravity Integration

Configure mcp-mesh as your single master MCP server in your claude_desktop_config.json or Cursor MCP settings:

{
  "mcpServers": {
    "mcp-mesh": {
      "command": "mcp-mesh",
      "args": ["run", "--config", "/path/to/mcp_mesh_config.json"]
    }
  }
}

Gateway Configuration (mcp_mesh_config.json)

Tip: Instead of hand-writing this JSON configuration, use our companion package manager mcp-registry-cli to auto-configure tools:

uvx mcp-registry-cli add postgres github brave-search

List all your downstream MCP servers in standard JSON format:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxx"
      }
    },
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
    },
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
    }
  }
}

💻 CLI Commands

mcp-mesh includes an ergonomic CLI for diagnostics, remote daemon streaming, and discovery:

# 1. Environment & Upstream Health Check (flutter-doctor style diagnostics)
mcp-mesh doctor
# Or diagnose a specific configuration file:
mcp-mesh doctor --config mcp_mesh_config.json

# 2. Start HTTP/SSE gateway daemon for remote or containerized agents
mcp-mesh sse --port 8000 --host 0.0.0.0

# 3. Start standard MCP stdio proxy gateway for Claude / Cursor / Antigravity
mcp-mesh run --config mcp_mesh_config.json

# 4. View token savings and server aggregation stats
mcp-mesh stats

# 5. Test natural language tool search from terminal
mcp-mesh search "commit code and create pull request"

# 6. Inspect full JSON schema for an indexed tool
mcp-mesh inspect github::create_pull_request

# 7. Run zero-config demonstration suite
mcp-mesh demo

🧪 Testing

The repository maintains a comprehensive automated test suite testing the JSON-RPC engine, keyword indexer, dynamic LRU cache, health doctor, SSE transport, and gateway protocol:

# Run all unit tests
python -m unittest discover -s tests -v

All 36+ tests execute synchronously using standard library unittest with zero setup.


🗺️ Roadmap & Ecosystem

mcp-mesh serves as the Flagship Project of the Existential Cloud AI Studio.

  • Phase 1: Core Engine (v1.0.0 & v1.1.0) - Zero-dependency stdio proxy, token indexer, dynamic LRU schema cache, mcp-mesh doctor, and SSE remote transport.

  • Phase 2: mcp-mesh-eval (Satellite 1) - Frontier benchmark harness evaluating 60 tools across September 2026 models (Repo).

  • Phase 3: mcp-mesh monitor (Satellite 2) - Real-time terminal telemetry monitor (mcp-mesh monitor) streaming live tool invocations and latency.

  • Phase 4: mcp-registry-cli (Satellite 3) - Zero-config community package manager discovering and auto-installing MCP servers directly into mcp-mesh (Repo).


🤝 Contributing

Contributions, feedback, and issue reports are warmly welcomed:

  1. Fork the repository.

  2. Create your feature branch (git checkout -b feature/dynamic-lru-cache).

  3. Commit your changes with semantic commit messages (git commit -m 'feat: add LRU cache for active schemas').

  4. Ensure all tests pass (python -m unittest discover -s tests).

  5. Open a Pull Request.


📄 License

Distributed under the MIT License. See LICENSE for complete details.


Crafted with 🖤 by Van Schulist | Existential Cloud

Available Tools

4 tools
mesh_describe_toolA

Inspect the full JSON schema and detailed parameter specifications of a specific tool before invoking it.

ParametersJSON Schema
NameRequiredDescriptionDefault
serverYesThe downstream server ID hosting the tool.
tool_nameYesThe target tool name to inspect.

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full disclosure burden. "Inspect" correctly implies a read-only, non-mutating operation, but nothing is said about error behavior when the server or tool_name is invalid, permission requirements, or whether the output is large. Adequate but shallow for a zero-annotation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with no filler; the purpose and the timing of use are packed into one line with nothing wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a two-parameter, read-only inspection tool with no output schema, the description covers what it returns (schema and parameter specs) and when to call it. Only minor gaps remain, such as failure behavior for unknown server/tool_name.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and both parameters (server, tool_name) are documented in the schema itself. The description adds no format, constraint, or naming guidance beyond what the schema already provides, so it sits at the baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb (inspect) and resource (full JSON schema and parameter specifications of a specific tool), which is clearly distinct from sibling verbs like mesh_search_tools and mesh_invoke_tool. It stops short of naming those siblings explicitly, but the action is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

"Before invoking it" states a clear condition for use, effectively positioning this as the pre-flight step to mesh_invoke_tool. There is no explicit when-not guidance or named alternative, but the context of use is well established.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

mesh_invoke_toolC

Directly execute any tool on a downstream MCP server. Pass server ID, target tool name, and input arguments dictionary.

ParametersJSON Schema
NameRequiredDescriptionDefault
serverYesThe downstream server ID (e.g. 'github', 'postgres').
argumentsNoJSON arguments matching the tool's parameter schema.
tool_nameYesThe exact tool name to execute.

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full behavioral burden. It conveys a direct proxy execution capability but omits critical context such as side effects, permission requirements, error handling, or whether the call is potentially destructive. For a tool that can execute arbitrary downstream tools, this is a major gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the core action, and free of redundant or filler content. Every clause contributes to the purpose or parameter mapping.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema and annotations, the description should explain what the tool returns or how errors surface. It covers purpose and parameters but leaves return values and failure modes entirely unspecified, which is incomplete for a generic invocation proxy.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so each parameter is already documented in the schema. The description merely restates the three parameters ('server ID, target tool name, input arguments dictionary') without adding format details or constraints. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb ('execute') and resource ('any tool on a downstream MCP server'), making the action unambiguous. However, it does not explicitly differentiate itself from siblings like mesh_search_tools or mesh_describe_tool, though the execution focus is clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No when-to-use guidance is provided. The description never mentions alternatives (e.g., search or describe first) or conditions that would favor this tool over discovery siblings. Usage is only implied by the verb.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

mesh_search_toolsB

Search for relevant tools across all aggregated MCP servers using natural language keywords (e.g. 'git commit', 'read file', 'query postgres'). Returns ultra-compact signatures and relevance scores.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum candidate tools to return (default: 5).
queryYesKeywords or functional goal describing the desired tool.
serverNoOptional downstream server ID to restrict search.

TDQS

B3.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, and it does disclose scope and return shape ('across all aggregated MCP servers', 'ultra-compact signatures and relevance scores'). It omits any statement about cost, latency, result ranking behavior, or what happens with an empty/miss result, which an agent would want for a cross-server fan-out search.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two compact sentences, purpose front-loaded, examples parenthetically embedded without bloat. No filler, though the parenthetical examples are the only slight padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, so the description rightly mentions the return format (signatures + relevance scores), and all three parameters are schema-documented. For a discovery tool with no annotations it is largely sufficient, missing only ranking/pagination behavior and explicit sibling routing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents query, limit and server. The keyword examples in the description add modest interpretive value for how to phrase 'query', but nothing beyond that; baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb ('Search') and resource ('tools across all aggregated MCP servers') plus concrete keyword examples ('git commit', 'read file'). It clearly contrasts implicitly with mesh_invoke_tool/mesh_describe_tool by framing itself as discovery, but never names those siblings to make the distinction explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It says how to search (natural language keywords) but not when to reach for this tool versus mesh_describe_tool, mesh_invoke_tool or mesh_status, and no workflow (search -> describe -> invoke) is suggested. Usage is only faintly implied by the tool's name.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

mesh_statusA

Inspect real-time gateway statistics: connected downstream servers, total tools indexed, and estimated context token savings.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the safety profile; 'inspect' reasonably implies a read-only, side-effect-free call, and 'real-time' is a useful disclosure about freshness. It does not state whether calling it consumes tokens, requires an active connection, or what happens if no servers are connected.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with a colon-separated list of what is returned; no filler, no restatement of the tool name.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter, zero-annotation read tool with no output schema, the description covers the essentials of what is returned. It is only slightly short of complete because it omits read-only confirmation and any failure/empty-state behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes zero parameters, so the baseline is 4; the description correctly presents it as a no-argument call and spends its words on the returned data instead of inventing parameter detail.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (inspect) and resource (real-time gateway statistics) and enumerates the three things returned: connected downstream servers, indexed tools, and token savings. That is far more specific than the siblings' search/describe/invoke surface, though it never names or contrasts them explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to call this versus mesh_search_tools or mesh_describe_tool, nor any stated prerequisite (e.g., call before or after connecting servers). Usage is only implied by the word 'inspect'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv1.0.0
    • First observedmesh_describe_tool
    • First observedmesh_invoke_tool
    • First observedmesh_search_tools
    • First observedmesh_status

TDQS

A3.6/5.0

Scored across 4 tools

Disambiguation5/5

Each tool targets a distinct phase of the gateway workflow: search, describe, invoke, and status. There is no overlap or ambiguity between them.

Naming Consistency4/5

All names use the 'mesh_' prefix and snake_case, but 'mesh_status' is a noun while the others follow a verb_noun pattern. This is a minor deviation that remains predictable and readable.

Tool Count5/5

Four tools are well-scoped for a gateway that aggregates many downstream servers. Each tool serves a clear, non-redundant purpose, and the count is neither too thin nor excessive.

Completeness4/5

The core gateway lifecycle is covered: discovery via search, inspection via describe, execution via invoke, and monitoring via status. A minor gap exists in not providing a direct 'list all servers/tools' operation without keywords, but agents can work around this.

Maintenance

ActivityMaintained
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Acts as a proxy for multiple MCP servers, reducing context window usage from 15,000+ tokens to ~500 tokens by dynamically loading servers on-demand and exposing only 3 tools instead of all tool definitions.
    5
    GPL 3.0
  • F
    license
    A
    quality
    A
    maintenance
    A multiplexing gateway that aggregates multiple MCP servers into a single port, significantly reducing context token usage through a Meta-MCP discovery system. It enables dynamic tool discovery and invocation across various transport protocols including stdio, HTTP, and SSE.
    15
    78
    -
  • A
    license
    Not graded
    quality
    A
    maintenance
    Aggregates tools from multiple upstream MCP servers and exposes them through 4 meta-tools, enabling LLMs to discover and use hundreds of tools without loading all schemas upfront.
    149 PyPI
    3
    Apache 2.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    A single MCP endpoint for AI agents to browse, inspect, and call tools from multiple upstream MCP servers without loading all schemas upfront, reducing context overhead.
    7 npm
    ISC