withcodemode
An MCP server proxy that compresses a Remote MCP server into a single tool, running it in a codemode agent loop.
Why?
MCP servers are great, but they can be limited by the context length of the model you're using.
withcodemode lets you compress all the tools available on a remote MCP server into a single tool, and then use a code generation agent to achieve the user's goal.
How it works
We create a typescript SDK based upon the tools available on the remote MCP server, and use this to generate code that achieves the user's goal.
If the code fails, the code generation agent will generate new code and try again. This process repeats until the code succeeds and we have a result that achieves the user's goal (or a maximum number of attempts is reached).
We have auth support - if the remote MCP server requires authentication, we'll send the auth url to authenticate.
Deploy to Cloudflare
Prerequisites
- Cloudflare account with Workers and Dynmaic Worker Loaders enabled
- OpenAI API key
- Your favourite Remote MCP server
Setup
- Clone and install:
git clone https://github.com/jaw9c/withcodemode.git
cd withcodemode
pnpm i- Set up secrets:
wrangler secret put OPENAI_API_KEY wrangler env set REMOTE_SERVER_URL wrangler env set TOOL_NAME wrangler env set TOOL_DESCRIPTION
- Deploy:
Connect Your MCP Client
Add this server to your MCP client configuration. For Claude Desktop:
{
"mcpServers": {
"sandbox": {
"url": "https://withcodemode.yourdomain.workers.dev/mcp"
}
}
}Usage
Once connected, your AI assistant has access to these tools:
use_<tool_name>
Start a coding task. Returns immediately with a runId to check later.
{ request: string, // The user's raw input. Do not interpret the prompt in any way. Do not add any additional information to the prompt. debug: boolean, // Whether to debug the tool execution }
Local Development
For local development and testing:
cp .dev.vars.example .dev.vars # Then fill in your secrets pnpm run dev # Start local server
Acknowledgements
This project is inspired by the following projects:
- CodeAct - Apple's research on code generation and execution
- Cloudflare CodeMode - Cloudflare's research on code generation and execution
- Cloudflare Agents - Cloudflare's framework for building agents