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

相关推荐
badfl7 小时前
OpenAI最新模型gpt-image-2:介绍、API价格、使用教程全汇总
人工智能·gpt·ai
亿电连接器替代品网8 小时前
Bulgin连接器在自动化与能源系统中的应用及国产替代策略
大数据·网络·人工智能·经验分享·物联网·硬件工程·材料工程
Tutankaaa14 小时前
从被动接受到主动挑战:知识竞赛如何重塑学习价值
人工智能·经验分享·笔记·学习
Jmayday15 小时前
机器学习基本理论
人工智能·机器学习
ZhengEnCi15 小时前
01b-上下文向量与信息瓶颈
人工智能
王_teacher15 小时前
机器学习 矩阵求导 完整公式+严谨推导
人工智能·线性代数·考研·机器学习·矩阵·线性回归
码以致用16 小时前
DeerFlow Memory架构
人工智能·ai·架构·agent
ting945200016 小时前
从零构建大模型实战:数据处理与 GPT-2 完整实现
人工智能
学点程序16 小时前
Manifest:帮个人 AI Agent 降低模型成本的开源路由器
人工智能·开源
孟健16 小时前
hermes101.dev 上线了!5 分钟装完、7 天入门、OpenClaw 老用户无痛迁移
ai编程