One prompt. One code block. Multiple MCP servers working together. CodeMesh lets agents write TypeScript code to orchestrate ANY MCP server - automatically.
Inspired by Cloudflare's Code Mode pattern, reimagined for the MCP ecosystem.
The only MCP server that gets smarter with every use
Agents document unclear outputs. Future agents benefit. Proven: Agent B one-shots what Agent A struggled with!
Coordinate tools from different MCP servers in a single code block. HTTP, stdio, websocket all supported.
Load only the tools you need. Tiered discovery prevents context pollution. 3 tools vs 50+.
Point to your MCP servers and go. No complex setup, no schema definitions, no boilerplate code.
Authentication, error handling, multi-transport support. Battle-tested and ready to deploy.
Environment variable substitution. Principle of least privilege. Safe to commit configs.
Three automatic steps from prompt to result
Watch the complete workflow: discover → get APIs → execute code (with auto-augmentation in action!)
You ask Claude:
"Use CodeMesh to give me the top 3 weather alerts for San Francisco, CA"
Behind the scenes, CodeMesh automatically:
Context-efficient discovery - only tool names and descriptions
geocodeServer.geocode
- Convert "San Francisco, CA" to coordinates
weatherServer.getAlerts
- Fetch weather alerts by stateGenerates TypeScript functions with augmentation docs
// CodeMesh generates these APIs for the agent:
geocodeServer.geocode({ location: string })
weatherServer.getAlerts({ state: string })
Agent writes TypeScript, CodeMesh executes in secure sandbox
// Agent writes this code automatically:
const coords = await geocodeServer.geocode({
location: "San Francisco, CA"
});
const alerts = await weatherServer.getAlerts({
state: coords.state
});
const alertsData = JSON.parse(alerts.content[0].text);
// Filter to top 3 by severity
const top3 = alertsData.features
.sort((a, b) => severityRank(a) - severityRank(b))
.slice(0, 3);
return top3;
You get intelligent results - no manual tool calls, no trial-and-error, just results! 🎯
The world's first self-improving MCP server
When agents encounter unclear tool outputs, they're forced to document what they learned. This knowledge becomes part of the system, helping all future agents succeed faster.
Agent needs to get file size but isn't sure what format filesystemServer.getFileInfo
returns.
// EXPLORING: What format does this return?
const result = await filesystemServer.getFileInfo({ path: 'package.json' });
console.log(result.content[0].text);
// Output (bespoke format!):
// size: 38075
// created: Tue Sep 30 2025 10:52:47 GMT-0400
// modified: Tue Sep 30 2025 10:52:47 GMT-0400
// isDirectory: false
// isFile: true
// permissions: 644
CodeMesh forces agent to document the output format with parsing examples.
## Output Format
Returns newline-delimited key-value pairs: `key: value`
### Fields
- size: File size in bytes (number)
- isDirectory: Boolean (true/false)
- isFile: Boolean (true/false)
- permissions: Unix permissions (e.g., "644")
### Parsing Example
const text = result.content[0].text;
const info = Object.fromEntries(
text.split('\n').map(line => line.split(': '))
);
console.log(info.size); // "38075"
Now every agent knows how to parse file info. No more trial-and-error!
// Agent gets augmented JSDoc with parsing example!
const result = await filesystemServer.getFileInfo({ path: 'data.json' });
// Agent knows exact format and how to parse
const text = result.content[0].text;
const info = Object.fromEntries(text.split('\n').map(line => line.split(': ')));
const fileSizeBytes = parseInt(info.size);
console.log(`File size: ${fileSizeBytes} bytes`);
// ✅ Success on first try!
Validated: Agent A explored and documented. Agent B one-shot the same task. This is compound intelligence in action! 🎉
Four simple steps to orchestrate ANY MCP server with agents.
Add CodeMesh to your Claude desktop config or MCP client
Copy your existing MCP server configs to .codemesh/config.json
Tell your agent what to do:
"Use codemesh to get the current weather for San Francisco"
Agent writes TypeScript, coordinates multiple servers, returns results