Claude Code MCP Server

by steipete
Integrations
  • 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-customCLAUDE_CLI_NAME=claude-v2
    • 绝对路径: CLAUDE_CLI_NAME=/path/to/custom/claude

    不允许使用相对路径(例如, ./claude../claude ),否则会引发错误。

    当设置为简单名称时,服务器将在以下位置查找指定的二进制文件:

    1. 系统 PATH(而不是默认的claude命令)

    注意:仍将检查本地用户安装路径( ~/.claude/local/claude ),但仅针对默认的claude二进制文件。

  • MCP_CLAUDE_DEBUG :启用调试日志记录(设置为true以获得详细输出)

安装与使用

使用此服务器的推荐方法是使用npx安装它。

"claude-code-mcp": { "command": "npx", "args": [ "-y", "@steipete/claude-code-mcp@latest" ] },

要使用自定义 Claude CLI 二进制名称,您可以指定环境变量:

"claude-code-mcp": { "command": "npx", "args": [ "-y", "@steipete/claude-code-mcp@latest" ], "env": { "CLAUDE_CLI_NAME": "claude-custom" } },

重要的首次设置:接受权限

在 MCP 服务器能够成功使用claude_code工具之前,您必须先使用--dangerously-skip-permissions标志手动运行一次 Claude CLI,登录并接受条款。

这是 Claude CLI 的一次性要求。

npm install -g @anthropic-ai/claude-code
claude --dangerously-skip-permissions

按照提示接受。完成后,MCP 服务器将能够以非交互方式使用该标志。

macOS 可能会在工具首次运行时请求所有类型的文件夹权限,因此首次运行会失败。后续运行将会成功。

连接到您的 MCP 客户端

设置服务器后,您需要配置您的 MCP 客户端(如 Cursor 或其他使用mcp.jsonmcp_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 工具(例如, BashReadWrite )。常用工具默认启用。

MCP 请求示例:

{ "toolName": "claude_code:claude_code", "arguments": { "prompt": "Refactor the function foo in main.py to be async." } }

示例

以下是服务器运行的一些视觉示例:

修复 ESLint 设置

下面是使用 Claude Code MCP 工具通过删除旧配置文件并创建新配置文件来以交互方式修复 ESLint 设置的示例:

列出文件示例

以下是 Claude Code 工具列出目录中文件的示例:

关键用例

该服务器通过其统一的claude_code工具,让您的 AI 能够直接访问 Claude Code CLI,从而解锁各种强大的功能。以下是您可以实现的一些示例:

  1. 代码生成、分析和重构:
    • "Generate a Python script to parse CSV data and output JSON."
    • "Analyze my_script.py for potential bugs and suggest improvements."
  2. 文件系统操作(创建、读取、编辑、管理):
    • 创建文件: "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'."
  3. 版本控制(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."
  4. 运行终端命令:
    • "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."
  5. 网页搜索和摘要:
    • "Search the web for 'benefits of server-side rendering' and provide a concise summary."
  6. 复杂的多步骤工作流程:
    • 自动更新版本、更新变更日志和标签发布: "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."
  7. 修复有语法错误的文件:
    • "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."
  8. 与 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.'"
  9. 与 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.jsonCHANGELOG.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_DEBUGtrue ,错误消息或日志可能会干扰 MCP 的 JSON 解析。设置为false可正常运行。
  • **ESM/导入错误:**确保您使用的是 Node.js v20 或更高版本。

对于开发人员:本地设置和贡献

如果您想开发或贡献此服务器,或从克隆的存储库运行它进行测试,请参阅我们的本地安装和开发设置指南

测试

该项目包括全面的测试套件:

# Run all tests npm test # Run unit tests only npm run test:unit # Run e2e tests (with mocks) npm run test:e2e # Run e2e tests locally (requires Claude CLI) npm run test:e2e:local # Watch mode for development npm run test:watch # Coverage report npm run test:coverage

有关详细的测试文档,请参阅我们的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.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

允许 LLM 自动绕过所有权限运行 Claude 代码的服务器,从而无需中断权限即可执行代码和编辑文件。

  1. 概述
    1. 好处
      1. 先决条件
        1. 配置
          1. 环境变量
        2. 安装与使用
          1. 重要的首次设置:接受权限
            1. 连接到您的 MCP 客户端
              1. MCP配置文件
            2. 提供的工具
              1. claude_code
              2. 示例
              3. 修复 ESLint 设置
              4. 列出文件示例
            3. 关键用例
              1. 纠正 GitHub Actions 工作流程
              2. 复杂的多步骤操作
            4. 故障排除
              1. 测试
                1. 通过环境变量配置
                  1. 贡献
                    1. 执照

                      Related MCP Servers

                      • A
                        security
                        A
                        license
                        A
                        quality
                        Allows LLMs to execute Python code in a specified Conda environment, enabling access to necessary libraries and dependencies for efficient code execution.
                        Last updated -
                        1
                        74
                        JavaScript
                        MIT License
                        • Linux
                        • Apple
                      • -
                        security
                        F
                        license
                        -
                        quality
                        A secure server that allows LLM applications like Claude to execute whitelisted system commands with user confirmation and comprehensive security features.
                        Last updated -
                        Python
                        • Linux
                        • Apple
                      • A
                        security
                        F
                        license
                        A
                        quality
                        Provides a secure, isolated JavaScript execution environment with configurable time and memory limits for safely running code from Claude.
                        Last updated -
                        1
                        5
                        JavaScript
                        • Apple
                      • -
                        security
                        A
                        license
                        -
                        quality
                        A 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 -
                        23
                        MIT License
                        • Apple
                        • Linux

                      View all related MCP servers

                      MCP directory API

                      We provide all the information about MCP servers via our MCP API.

                      curl -X GET 'https://glama.ai/api/mcp/v1/servers/steipete/claude-code-mcp'

                      If you have feedback or need assistance with the MCP directory API, please join our Discord server