Claude Code中英文系列教程30:将 Claude Code 作为 MCP 服务器对外提供服务

You can use Claude Code itself as an MCP server that other applications can connect to:

您可以将 Claude Code 本身用作其他应用程序可以连接的 MCP 服务器:

bash 复制代码
# Start Claude as a stdio MCP server
claude mcp serve

You can use this in Claude Desktop by adding this configuration to claude_desktop_config.json:

您可以向 claude_desktop_config.json 添加下面配置在 Claude Desktop 中使用:

bash 复制代码
{
  "mcpServers": {
    "claude-code": {
      "type": "stdio",
      "command": "claude",
      "args": ["mcp", "serve"],
      "env": {}
    }
  }
}

Configuring the executable path: The command field must reference the Claude Code executable. If the claude command is not in your system's PATH, you'll need to specify the full path to the executable.

配置可执行路径: command 字段必须引用 Claude Code 可执行文件。如果 claude 命令不在您的系统 PATH 中,您需要指定可执行文件的完整路径。

To find the full path:

要找到完整路径:

which claude

Then use the full path in your configuration:

然后在你的配置中使用完整路径:

bash 复制代码
{
  "mcpServers": {
    "claude-code": {
      "type": "stdio",
      "command": "/full/path/to/claude",
      "args": ["mcp", "serve"],
      "env": {}
    }
  }
}

Without the correct executable path, you'll encounter errors like spawn claude ENOENT.

如果没有正确的可执行路径,你将遇到像 spawn claude ENOENT 这样的错误。

Tips: 提示:

The server provides access to Claude's tools like View, Edit, LS, etc.

服务器提供对 Claude 的工具(如 View、Edit、LS 等)的访问。

In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.

在 Claude 桌面版中,尝试让 Claude 读取目录中的文件、进行编辑等操作。

Note that this MCP server is only exposing Claude Code's tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.

请注意,这个 MCP 服务器仅向您的 MCP 客户端暴露 Claude Code 的工具,因此您的客户端负责为单个工具调用实现用户确认。

不过我在vscode里面配置后对vscode本身好像有点影响。

相关推荐
小小测试开发1 小时前
安装 Python 3.10+
开发语言·人工智能·python
KaMeidebaby2 小时前
卡梅德生物技术快报|PD1 单克隆抗体定制配套 N 糖全谱质控开发
前端·人工智能·算法·数据挖掘·数据分析
我叫唧唧波2 小时前
Python+AI 全栈学习笔记
人工智能·python·学习
Jartto3 小时前
手搓一个 Claude Code 硬件副屏:3D 打印外壳 + 本地状态机实现 AI 任务可视化
aigc·ai编程·claude
哈哈,柳暗花明3 小时前
人工智能专业术语详解(E)
人工智能·专业术语
AI极客菌3 小时前
AI绘画工具中,为什么专业玩家爱用Stable Diffusion,普通玩家却喜欢Midjourney?
大数据·人工智能·ai·ai作画·stable diffusion·aigc·midjourney
人工智能AI技术3 小时前
FLUX.2[klein]开源!小香蕉平替,本地部署AI绘画的极简方案
人工智能·ai作画·aigc
腾视科技AI3 小时前
腾视科技大模型一体机解决方案:低成本私有化落地,重塑行业智能应用新格局
大数据·人工智能·科技·ai·边缘计算·算力·ai算力
pusheng20253 小时前
IFSJ全英文专访:中国创新力量重塑先进气体感知技术,赋能全球关键基础设施安全
前端·网络·人工智能·物联网·安全
魔点科技3 小时前
魔点门禁门常开计划解决早高峰排队、忘落锁、多门手动调模式痛点
人工智能·智能硬件·智能门禁·考勤门禁·魔点科技