Supports Linux systems with dedicated configuration paths for connecting to MCP clients
Provides integration with the macOS operating system through specific configuration paths for connecting to MCP clients
Offers integration with Node.js applications through the Claude Code tool and file editing capabilities
Claude 代码 MCP 服务器
MCP(模型上下文协议)服务器允许在一次性模式下运行 Claude 代码,并自动绕过权限。
您是否注意到,Cursor 有时会在执行复杂的多步骤编辑或操作时遇到困难?这款服务器配备强大的统一claude_code
工具,旨在使 Claude 成为您编码任务更直接、更强大的代理。
概述
此 MCP 服务器提供了一个工具,可供 LLM 与 Claude Code 交互。当与 Claude Desktop 或其他 MCP 客户端集成时,它允许 LLM 执行以下操作:
- 运行 Claude Code 并绕过所有权限(使用
--dangerously-skip-permissions
) - 执行克劳德代码,无需任何许可中断
- 直接访问文件编辑功能
- 默认启用特定工具
好处
- Claude/Windsurf 编辑文件经常出问题。Claude Code 在这方面做得更好,速度也更快。
- 可以将多个命令排队执行,而不是直接执行。这节省了上下文空间,因此更重要的内容可以保留更长时间,从而减少压缩操作。
- 文件操作、git 或其他操作不需要昂贵的模型。如果您注册了 Antropic Max,Claude Code 会非常划算。您可以在 Max 模式下使用 Gemini 或 o3,并将任务转移到更便宜的模型上,从而节省成本。
- Claude 具有更广泛的系统访问权限,可以做 Cursor/Windsurf 做不到的事情(或者认为它们做不到的事情),因此每当它们被卡住时,只要让它们“使用 Claude 代码”,通常就可以解除卡住。
- 代理规则中的代理。
先决条件
- Node.js v20 或更高版本(使用 fnm 或 nvm 安装)
- Claude CLI 在本地安装(运行它并调用 /doctor)并接受
-dangerously-skip-permissions
。
配置
环境变量
CLAUDE_CLI_NAME
:覆盖 Claude CLI 二进制文件名称或提供绝对路径(默认值:claude
)。这允许您使用自定义的 Claude CLI 二进制文件。这在以下情况下很有用:- 使用自定义 Claude CLI 包装器
- 使用模拟二进制文件进行测试
- 并排运行多个 Claude CLI 版本
支持的格式:
- 简单名称:
CLAUDE_CLI_NAME=claude-custom
或CLAUDE_CLI_NAME=claude-v2
- 绝对路径:
CLAUDE_CLI_NAME=/path/to/custom/claude
不允许使用相对路径(例如,
./claude
或../claude
),否则会引发错误。当设置为简单名称时,服务器将在以下位置查找指定的二进制文件:
- 系统 PATH(而不是默认的
claude
命令)
注意:仍将检查本地用户安装路径(
~/.claude/local/claude
),但仅针对默认的claude
二进制文件。MCP_CLAUDE_DEBUG
:启用调试日志记录(设置为true
以获得详细输出)
安装与使用
使用此服务器的推荐方法是使用npx
安装它。
要使用自定义 Claude CLI 二进制名称,您可以指定环境变量:
重要的首次设置:接受权限
在 MCP 服务器能够成功使用claude_code
工具之前,您必须先使用--dangerously-skip-permissions
标志手动运行一次 Claude CLI,登录并接受条款。
这是 Claude CLI 的一次性要求。
按照提示接受。完成后,MCP 服务器将能够以非交互方式使用该标志。
macOS 可能会在工具首次运行时请求所有类型的文件夹权限,因此首次运行会失败。后续运行将会成功。
连接到您的 MCP 客户端
设置服务器后,您需要配置您的 MCP 客户端(如 Cursor 或其他使用mcp.json
或mcp_config.json
客户端)。
MCP配置文件
配置通常在 JSON 文件中完成。名称和位置可能因客户端而异。
光标
光标使用mcp.json
。
- macOS:
~/.cursor/mcp.json
- Windows:
%APPDATA%\\Cursor\\mcp.json
- Linux:
~/.config/cursor/mcp.json
风帆冲浪
Windsurf 用户使用mcp_config.json
- macOS:
~/.codeium/windsurf/mcp_config.json
- Windows:
%APPDATA%\\Codeium\\windsurf\\mcp_config.json
- Linux:
~/.config/.codeium/windsurf/mcp_config.json
(注意:在某些混合设置中,如果也安装了 Cursor,这些客户端可能会回退到使用 Cursor 的~/.cursor/mcp.json
路径。如果使用 Codeium 扩展,请优先考虑 Codeium 特定的路径。)
如果不存在,请创建此文件。添加或更新claude_code
的配置:
提供的工具
该服务器公开了一个主要工具:
claude_code
使用带有--dangerously-skip-permissions
的 Claude Code CLI 直接执行提示。
参数:
prompt
(字符串,必需):发送给 Claude Code 的提示。options
(对象,可选):tools
(字符串数组,可选):需要启用的特定 Claude 工具(例如,Bash
、Read
、Write
)。常用工具默认启用。
MCP 请求示例:
示例
以下是服务器运行的一些视觉示例:
修复 ESLint 设置
下面是使用 Claude Code MCP 工具通过删除旧配置文件并创建新配置文件来以交互方式修复 ESLint 设置的示例:
列出文件示例
以下是 Claude Code 工具列出目录中文件的示例:
关键用例
该服务器通过其统一的claude_code
工具,让您的 AI 能够直接访问 Claude Code CLI,从而解锁各种强大的功能。以下是您可以实现的一些示例:
- 代码生成、分析和重构:
"Generate a Python script to parse CSV data and output JSON."
"Analyze my_script.py for potential bugs and suggest improvements."
- 文件系统操作(创建、读取、编辑、管理):
- 创建文件:
"Your work folder is /Users/steipete/my_project\n\nCreate a new file named 'config.yml' in the 'app/settings' directory with the following content:\nport: 8080\ndatabase: main_db"
- 编辑文件:
"Your work folder is /Users/steipete/my_project\n\nEdit file 'public/css/style.css': Add a new CSS rule at the end to make all 'h2' elements have a 'color: navy'."
- 移动/复制/删除:
"Your work folder is /Users/steipete/my_project\n\nMove the file 'report.docx' from the 'drafts' folder to the 'final_reports' folder and rename it to 'Q1_Report_Final.docx'."
- 创建文件:
- 版本控制(Git):
"Your work folder is /Users/steipete/my_project\n\n1. Stage the file 'src/main.java'.\n2. Commit the changes with the message 'feat: Implement user authentication'.\n3. Push the commit to the 'develop' branch on origin."
- 运行终端命令:
"Your work folder is /Users/steipete/my_project/frontend\n\nRun the command 'npm run build'."
"Open the URL https://developer.mozilla.org in my default web browser."
- 网页搜索和摘要:
"Search the web for 'benefits of server-side rendering' and provide a concise summary."
- 复杂的多步骤工作流程:
- 自动更新版本、更新变更日志和标签发布:
"Your work folder is /Users/steipete/my_project\n\nFollow these steps: 1. Update the version in package.json to 2.5.0. 2. Add a new section to CHANGELOG.md for version 2.5.0 with the heading '### Added' and list 'New feature X'. 3. Stage package.json and CHANGELOG.md. 4. Commit with message 'release: version 2.5.0'. 5. Push the commit. 6. Create and push a git tag v2.5.0."
- 自动更新版本、更新变更日志和标签发布:
- 修复有语法错误的文件:
"Your work folder is /path/to/project\n\nThe file 'src/utils/parser.js' has syntax errors after a recent complex edit that broke its structure. Please analyze it, identify the syntax errors, and correct the file to make it valid JavaScript again, ensuring the original logic is preserved as much as possible."
- 与 GitHub 交互(例如创建拉取请求):
"Your work folder is /Users/steipete/my_project\n\nCreate a GitHub Pull Request in the repository 'owner/repo' from the 'feature-branch' to the 'main' branch. Title: 'feat: Implement new login flow'. Body: 'This PR adds a new and improved login experience for users.'"
- 与 GitHub 交互(例如检查 PR CI 状态):
"Your work folder is /Users/steipete/my_project\n\nCheck the status of CI checks for Pull Request #42 in the GitHub repository 'owner/repo'. Report if they have passed, failed, or are still running."
纠正 GitHub Actions 工作流程
复杂的多步骤操作
此示例说明了claude_code
如何处理更复杂、多步骤的任务,例如通过创建分支准备发布、更新多个文件( package.json
、 CHANGELOG.md
)、提交更改以及发起拉取请求,所有这些都在单个、连贯的操作中完成。
关键:请记住在文件系统或 git 操作提示中提供当前工作目录(CWD)上下文(例如, "Your work folder is /path/to/project\n\n...your command..."
)。
故障排除
- **“命令未找到”(claude-code-mcp):**如果是全局安装,请确保 npm 全局 bin 目录位于系统 PATH 中。如果使用
npx
,请确保npx
本身正常运行。 - **“未找到命令”(claude 或 ~/.claude/local/claude):**请确保 Claude CLI 已正确安装。运行
claude/doctor
或查看其文档。 - **权限问题:**确保您已运行“重要的首次设置”步骤。
- **来自服务器的 JSON 错误:**如果
MCP_CLAUDE_DEBUG
为true
,错误消息或日志可能会干扰 MCP 的 JSON 解析。设置为false
可正常运行。 - **ESM/导入错误:**确保您使用的是 Node.js v20 或更高版本。
对于开发人员:本地设置和贡献
如果您想开发或贡献此服务器,或从克隆的存储库运行它进行测试,请参阅我们的本地安装和开发设置指南。
测试
该项目包括全面的测试套件:
有关详细的测试文档,请参阅我们的E2E 测试指南。
通过环境变量配置
可以使用以下环境变量定制服务器的行为:
CLAUDE_CLI_PATH
:Claude CLI 可执行文件的绝对路径。- 默认:检查
~/.claude/local/claude
,然后回退到claude
(期望它在 PATH 中)。
- 默认:检查
MCP_CLAUDE_DEBUG
:设置为true
,即可从此 MCP 服务器获取详细调试日志记录。默认值:false
。
这些可以在您的 shell 环境中或mcp.json
服务器配置的env
块内进行设置(尽管为了简单起见,删除了mcp.json
示例中的env
块,但如果需要,它仍然是为服务器进程设置它们的有效方法)。
贡献
欢迎贡献!请参阅本地安装和开发设置指南,了解如何设置环境。
向GitHub 存储库提交问题和拉取请求。
执照
麻省理工学院
You must be authenticated.
local-only server
The server can only run on the client's local machine because it depends on local resources.
允许 LLM 自动绕过所有权限运行 Claude 代码的服务器,从而无需中断权限即可执行代码和编辑文件。
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityAllows LLMs to execute Python code in a specified Conda environment, enabling access to necessary libraries and dependencies for efficient code execution.Last updated -174JavaScriptMIT License
- -securityFlicense-qualityA secure server that allows LLM applications like Claude to execute whitelisted system commands with user confirmation and comprehensive security features.Last updated -Python
- AsecurityFlicenseAqualityProvides a secure, isolated JavaScript execution environment with configurable time and memory limits for safely running code from Claude.Last updated -15JavaScript
Fused MCP Agentsofficial
-securityAlicense-qualityA Python-based MCP server that allows Claude and other LLMs to execute arbitrary Python code directly through your desktop Claude app, enabling data scientists to connect LLMs to APIs and executable code.Last updated -23MIT License