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本身好像有点影响。

相关推荐
ADAI_Bowen几秒前
渲境AI实测:当AI尝试扛起建筑效果图的交付压力
大数据·人工智能
yi0111 分钟前
DAY27: LeetCode 110. 平衡二叉树 | 在递归中判断是否平衡
人工智能·笔记·python·算法·leetcode·二叉树·递归
Sammyyyyy2 分钟前
jev-ultrafast 实战:浏览器操作代理加本地 AI 网关,把云控制台配置做成自动化流水线
运维·人工智能·自动化·ai编程·servbay
狂师3 分钟前
爆火!新一代e2e AI测试框架,单日狂揽1500 star
前端·人工智能·测试
米小虾3 分钟前
随机基线都打不过:为什么一整代视觉 Token 压缩方法在混合线性注意力上集体失效
人工智能
米小虾4 分钟前
一条 rollout 的两种死法:RLVR 的学习信号漏在哪,怎么补
人工智能
啵啵啵鱼11 分钟前
对数据的增删改查
数据库·mysql·ai·idea·ai编程·navicat·obsidian
yychen_java12 分钟前
第十二篇:完整项目实战——构建可验证的能源智能运维 Agent 中枢
运维·人工智能·能源
loulanyue_15 分钟前
蚂蚁集团AI Native研发实践:从面向人类到面向Agent的下一代技术架构演进——读平台技术事业群总架构师黄挺2026云栖专场演讲
人工智能·大模型·软件架构·蚂蚁集团
HAHAXX817 分钟前
影刀AI点数是怎么消耗的?拆解消耗规则 + 成本优化实战
人工智能·rpa