
jx-codes/codemode-mcp 是从 https://github.com/jx-codes/codemode-mcp. 导入的 MCP 服务器候选
概览
jx-codes/codemode-mcp 是从 https://github.com/jx-codes/codemode-mcp. 导入的 MCP 服务器候选
概述(AI 翻译)
注:我已经停止了这个仓库的工作,转而专注于:
https://github.com/jx-codes/lootbox
这是一种更深思熟虑的代码模式
代码模式 MCP 服务器
MCP服务器“代码模式”工作流程的本地实现。LLM不再为多个工具调用而苦恼,而是编写TypeScript/JavaScript代码,调用一个简单的HTTP代理访问你的MCP服务器。
注意:它不尝试处理MCP -> typescript API 转译层。那会很酷,但我真的想测试一下工作流程。
https://blog.cloudflare.com/code-mode/
这是什么?
这实现了核心洞察:LLM在编写代码方面远胜于工具调用。该服务器没有直接向LLM暴露许多工具(它在这方面很吃力),而是只给LLM一个工具:execute_code。LLM编写代码,发送HTTP请求访问你的其他MCP服务器。
它是如何运作的
- LLM 获得一个工具:
execute_code- 执行 TypeScript/JavaScript - LLM 编写代码:使用
fetch()调用http://localhost:3001/mcp/*端点 - HTTP 代理转发:透明地将请求转发到你的实际 MCP 服务器
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
NOTE: I’ve stopped working on this repo in favor of:
https://github.com/jx-codes/lootbox
It’s a much more thought out approach to code mode
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/JavaScript - LLM writes code: Uses
fetch()to callhttp://localhost:3001/mcp/*endpoints - HTTP 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
git clone https://github.com/jx-codes/codemode-mcp.git
cd codemode-mcp
- Install dependencies
bun install
- Configure the server (optional)
Create a codemode-config.json file to customize settings:
{
"proxyPort": 3001,
"configDirectories": [
"~/.config/mcp/servers",
"./mcp-servers",
"./"
]
}
- Set up your MCP servers
Create a .mcp.json file with your MCP server configurations in any of the directories you specified above:
{
"mcpServers": {
"fs": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
"env": {}
}
}
}
Example Workflows
Single MCP Server Call
Instead of direct tool calling, the LLM writes:
// List available servers
const servers = await fetch("http://localhost:3001/mcp/servers").then((r) =>
r.json()
);
console.log("Available servers:", servers);
// Call a tool on the filesystem server
const result = await fetch("http://localhost:3001/mcp/call", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
server: "fs",
tool: "read_file",
args: { path: "/tmp/example.txt" },
}),
}).then((r) => r.json());
console.log("File contents:", result);
Chaining Multiple Operations
安装
npx -y @modelcontextprotocol/server-filesystem /tmp配置
{
"mcpServers": {
"fs": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
"env": {}
}
}
}