MCP Code Mode Server
基于 MCP 的"代码即工具"实现:在安全沙箱中执行 TypeScript 代码,通过 IPC 桥接调用 MCP servers。
测试覆盖率: 99.41% 语句 · 100% 行 · 100% 函数
快速开始
配置 Claude Desktop
配置文件位置
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
配置内容
注意: 替换为实际项目的绝对路径。
配置完成后,重启 Claude Desktop 即可使用。
使用示例
读取文件
写入文件
列出目录
网络请求
工作原理
子进程通过 IPC 向主进程发送 MCP 工具调用请求
主进程代理执行并返回结果
支持跨平台:macOS / Linux / Windows
项目结构
测试
覆盖率:99.41% 语句、100% 行、100% 函数
核心特性
IPC 桥接: 子进程安全调用主进程 MCP 工具
模块解析: 符号链接或目录拷贝(自动降级)
跨平台: macOS / Linux / Windows 完整支持
高测试覆盖率: 36 个测试用例,覆盖核心路径
生产就绪: 隔离执行、资源清理、超时控制
故障排查
Server 无法启动
检查是否已构建:
npm run build检查
dist/server.js是否存在确认 Node.js 版本 >= 18
代码执行失败
确保已生成 API:
npm run generate-api检查
generated-api/servers/目录是否存在验证导入路径:
./servers/...
Claude Desktop 看不到工具
检查配置文件路径是否正确
确保使用绝对路径
重启 Claude Desktop
查看开发者工具控制台日志
安全建议
代码在子进程中隔离执行
filesystem 工具默认限制访问范围
生产环境建议配置资源限制(CPU/内存)
可选:容器级/系统级额外隔离
License
MIT
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.
Executes TypeScript code in a secure sandbox with IPC-bridged access to MCP tools like filesystem operations and network requests.