Required runtime dependency for running the Code Mode MCP server and managing its dependencies
Provides a secure sandbox environment for executing TypeScript/JavaScript code with network access restrictions and timeout controls
Supports execution of JavaScript code as an alternative to TypeScript in the Code Mode workflow for MCP server orchestration
Enables execution of TypeScript code through the Code Mode workflow, allowing LLMs to write strongly-typed code for MCP server interactions
Code Mode MCP Server
A local implementation of the "Code Mode" workflow for MCP servers. Instead of struggling with multiple tool calls, LLMs write TypeScript/JavaScript code that calls a simple HTTP proxy to access your MCP servers.
Note: It does not attempt to handle the MCP -> typescript API transpilation layer. Would be cool but I really wanted to test the workflow.
https://blog.cloudflare.com/code-mode/
What is this?
This implements the core insight that LLMs are much better at writing code than at tool calling. Instead of exposing many tools directly to the LLM (which it struggles with), this server gives the LLM just one tool: execute_code
. The LLM writes code that makes HTTP requests to access your other MCP servers.
How it works
LLM gets one tool:
execute_code
- executes TypeScript/JavaScriptLLM writes code: Uses
fetch()
to callhttp://localhost:3001/mcp/*
endpointsHTTP proxy forwards: Transparently proxies requests to your actual MCP servers
Results flow back: Through the code execution to the LLM
This gives you all the benefits of complex tool orchestration, but leverages what LLMs are actually good at: writing code.
Installation
Prerequisites
Bun (latest version)
Deno (for code execution sandbox)
An MCP-compatible client (Claude Desktop, Cursor, VS Code with Copilot, etc.)
Setup
Clone the repository
Install dependencies
Configure the server (optional)
Create a codemode-config.json
file to customize settings:
Set up your MCP servers
Create a .mcp.json
file with your MCP server configurations in any of the directories you specified above:
Example Workflows
Single MCP Server Call
Instead of direct tool calling, the LLM writes:
Chaining Multiple Operations
The real power shows when chaining operations:
Tools
execute_code
Executes TypeScript/JavaScript code with network access to the MCP proxy.
Parameters:
code
(string): Code to executetypescript
(boolean): TypeScript mode (default: true)
Proxy Endpoints:
GET /mcp/servers
- List available MCP serversGET /mcp/{server}/tools
- List tools for serverPOST /mcp/call
- Call tool (body:{server, tool, args}
)
check_deno_version
Check Deno installation status.
list_servers_with_tools
Get a comprehensive overview of all available MCP servers and their tools. Returns structured JSON data optimized for LLM consumption, containing complete tool schemas and server status information.
JSON Output Structure:
This provides complete tool discovery information including parameter schemas, types, and requirements for programmatic access.
Configuration
Create codemode-config.json
:
Add your MCP servers to .mcp.json
files in those directories:
Why (Might) Work Better
Traditional MCP: LLM → Tool Call → MCP Server → Result → LLM → Tool Call → ...
LLMs struggle with tool syntax
Each call goes through the neural network
Hard to chain operations
Limited by training on synthetic tool examples
Code Mode: LLM → Write Code → Code calls proxy → Proxy forwards to MCP → Results
LLMs excel at writing code (millions of real examples in training)
Code can chain operations naturally
Results flow through code logic, not neural network
Natural composition and data processing
Security
Code runs in Deno sandbox with network access only
No filesystem, environment, or system access
30-second execution timeout
MCP servers accessed through controlled proxy
Temporary files auto-cleanup
Troubleshooting
"Deno not installed": Install Deno and restart
"Permission denied": Code trying to access restricted resources
"Module not found": Use https://
URLs for imports
"Execution timeout": Optimize code or break into smaller operations
TODO (Maybe)
Provide a simpler API layer for the MCP proxy something like mcp.tool('name', args);
Could easily be done by injecting our own typescript file into the Deno scope before running user code
More config options
Filter out the tools somehow
Test it out more in my workflows and see the results
Deno code remixed from: https://github.com/Timtech4u/deno-mcp-server
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables LLMs to interact with MCP servers by writing TypeScript/JavaScript code instead of direct tool calls. Provides a code execution sandbox that accesses MCP servers through HTTP proxy endpoints.