this is a little hack that I had Claude Code spin up for me and it only kinda half works. feel free to pirate it but don't expect much despite the fact that Claude Code does a great job of generating readmes that look like what you'd find in a finished product!Claude Code MCP 服务器
一个模型上下文协议(MCP)服务器,它允许Claude Desktop与Claude Code实例进行交互。这实现了不同Claude环境之间的远程控制和协调。
快速入门
- 安装依赖项:
npm install- 测试服务器:
npm start- 配置Claude桌面版:
添加到您的Claude Desktop MCP配置中(~/Library/Application Support/Claude/claude_desktop_config.json (在 macOS 上):
{
"mcpServers": {
"claude-code-bridge": {
"command": "node",
"args": ["/absolute/path/to/this/project/src/index.js"]
}
}
}可用工具
- 检查Claude代码安装情况验证Claude代码是否可用
- 执行Claude代码命令向Claude Code发送命令
- 开始Claude代码会话初始化一个新的Claude Code会话
- 通过Claude代码读取文件通过Claude Code读取文件
- 通过Claude代码写入文件通过Claude代码编写文件
在Claude桌面版中的示例用法
配置完成后,您可以在Claude桌面版中使用这些工具:
Check if Claude Code is installed on the systemStart a new Claude Code session in /path/to/project and ask it to analyze the codebaseExecute command: "Create a new React component called UserProfile"架构说明
这是一个展示概念的基本实现。服务器目前:
- 模拟Claude代码集成 (由于我们是在没有实际CLI的情况下进行构建的)
- 提供基础 一旦Claude Code CLI可用,即可实现真正的集成
- 展示MCP桥接模式 用于不同类别的通信(或:跨类别通信)
未来的改进/增强
- 真实克劳德代码集成 当CLI可用时
- 持久会话管理
- 双向通信
- 网络MCP服务器版本 用于远程访问
- 会话状态同步
- 错误处理和恢复
发展
# Run in development mode with auto-reload
npm run dev网络服务器扩展
要将此扩展以支持与 Claude.ai 网页/移动应用的协作,你需要:
- 添加HTTP/WebSocket传输 而不是stdio
- 实现身份验证/授权
- 添加会话管理
- 处理并发连接
- 作为网络服务进行部署
MCP协议已经支持这一点——只需交换传输层即可!
