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

相关推荐
u1301302 分钟前
GitHub 热榜项目:周榜(2026-11-01)
人工智能·github
lifallen10 分钟前
ub-mode skill:软件工程原则
人工智能·学习·ai·软件工程·ai编程
Geek-Chow19 分钟前
05.4 · DeepInfer 推理框架总览:源码结构、开源与未开源部分对照
人工智能
Flynn Liang21 分钟前
Spring AI 多模态实战(下):文生图 + TTS 语音合成(含 2.0 流式音频分片)
人工智能·spring·文生图·音视频·语音合成·tts·springai
长不大的杨瑞杰29 分钟前
OpenCode v2 Custom Tools 实战:开发数据库、工单与发布工具
人工智能·typescript·开发工具·opencode·custom tools
羊仔AI探索33 分钟前
离世仅仅半个月,张雪峰被蒸馏了
人工智能·aigc·蒸馏·张雪峰·skills
zhippt_10141 小时前
只剩截图没有源文件?图转PPT把图片还原成可编辑幻灯片
前端·人工智能·powerpoint
小oo呆1 小时前
【自然语言处理与大模型】自然语言处理的漫漫长路之深度学习时代
人工智能·深度学习·自然语言处理
JavaPub-rodert1 小时前
AI Agent 的记忆系统怎么设计?从短期记忆、长期记忆到 RAG,讲透 Memory 工程化
人工智能
智恒百亿1 小时前
一台 5090 八卡服务器怎么分给一个团队用?多模型多任务的显存分配实战
java·大数据·人工智能