PitchHut logo
codemcp
by
sky
Streamline multi-tool interactions with execute_python.
Pitch

Codemcp is a versatile MCP server that serves as a gateway to multiple upstream servers. It allows agents to seamlessly execute Python code that interacts with various tools in a single call, simplifying complex workflows and optimizing resource usage, making it easier to integrate multiple tool responses efficiently.

Description

codemcp – Meta-MCP "Code-Mode" Gateway

codemcp serves as a single MCP server that seamlessly connects to multiple upstream MCP servers, providing a streamlined access point through a singular tool: execute_python. This innovative approach allows agents to write Python code that invokes various upstream tools as typed functions, enabling the transformation and combination of results in-process without necessitating numerous sequential MCP tool calls.

Architecture Overview

The architecture is designed as follows:

agent harness ──MCP──► codemcp gateway ──MCP clients──► upstream servers
   (stdio/HTTP)         (one tool: execute_python)       (github, sentry, …)
                              │                            (stdio / streamable-http)
                              ├─ generates a typed Python SDK (1 fn per upstream tool)
                              ├─ runs Python in a worker process
                              └─ SDK fns call back into the gateway → route to upstream

The agent's LLM is limited to seeing only the execute_python tool, which is equipped with a description that includes a brief introduction and two lines summarizing each upstream tool with its full typed Python signature. The SDK is preloaded into the Python runtime, ensuring it is efficient and never concatenated into the per-call code string.

Efficient Task Execution

Consider a common agent task such as, "find the open issue mentioning X, fetch its linked PR, and summarize the diff." Traditionally, this task would involve multiple round-trips to the model, each requiring the re-sending of tool schemas and intermediate JSON data. With codemcp, this can be accomplished in a single Python snippet:

issue = github_search_issues(query="X", state="open")[0]
pr = github_get_pull_request(number=issue["linked_pr"])
result = {"title": pr["title"], "files_changed": len(pr["files"])}

This not only simplifies the code but significantly reduces the round-trips needed, returning only the final result.

Performance Benchmarks

A set of repeatable experiments, detailed in bench/, compares token usage between the traditional direct MCP and the codemcp approach across three read-only queries over the GitHub user skymoore's data. Each method utilizes the same model (claude-sonnet-4-6) and upstream GitHub MCP server, revealing notable efficiency improvements:

armwhat the model sees
directall ~41 GitHub tools bound directly (large per-turn tool schema)
codemcpone execute_python tool whose description lists ~41 two-line signatures

The results indicate that while tasks executed directly remain consistent in input token usage, codemcp markedly reduces input token counts by up to 90% for multi-tool tasks.

Features of codemcp

  • Tool Discovery: Automatically connects to and discovers tools from upstream MCP servers.
  • Typed Python SDK Generation: Generates a typed SDK from each tool's JSON Schema, ensuring a clear interface for developers.
  • Secure Execution: Executes user-defined Python code within a persistent worker, safely managing SDK callbacks to the appropriate upstream servers.
  • Runtime Management: Admin commands allow for dynamic enabling or disabling of upstream connections without restarting the server, facilitating flexible and adaptable environments.

Future Plans

Future expansions for codemcp include:

  • Enhanced isolation modes for executing untrusted agents.
  • Implementation of Monty in-process sandboxing.
  • Development of LLM-generated summaries for upstream tool descriptions.

Running codemcp

codemcp is designed for ease of integration into existing environments, with potential configuration from harness setups or manual configuration through JSON files. The gateway mechanism allows interaction with multiple upstream servers, presenting a powerful, unified interface for multi-tool integrations.

For further details, including sample benchmarks and methods to set up your own codemcp environment, refer to the sections in the repository.

0 comments

No comments yet.

Sign in to be the first to comment.