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

相关推荐
九.九7 小时前
ops-transformer:AI 处理器上的高性能 Transformer 算子库
人工智能·深度学习·transformer
春日见7 小时前
拉取与合并:如何让个人分支既包含你昨天的修改,也包含 develop 最新更新
大数据·人工智能·深度学习·elasticsearch·搜索引擎
恋猫de小郭7 小时前
AI 在提高你工作效率的同时,也一直在增加你的疲惫和焦虑
前端·人工智能·ai编程
deephub7 小时前
Agent Lightning:微软开源的框架无关 Agent 训练方案,LangChain/AutoGen 都能用
人工智能·microsoft·langchain·大语言模型·agent·强化学习
大模型RAG和Agent技术实践8 小时前
从零构建本地AI合同审查系统:架构设计与流式交互实战(完整源代码)
人工智能·交互·智能合同审核
老邋遢8 小时前
第三章-AI知识扫盲看这一篇就够了
人工智能
互联网江湖8 小时前
Seedance2.0炸场:长短视频们“修坝”十年,不如AI放水一天?
人工智能
PythonPioneer8 小时前
在AI技术迅猛发展的今天,传统职业该如何“踏浪前行”?
人工智能
冬奇Lab8 小时前
一天一个开源项目(第20篇):NanoBot - 轻量级AI Agent框架,极简高效的智能体构建工具
人工智能·开源·agent
阿里巴巴淘系技术团队官网博客9 小时前
设计模式Trustworthy Generation:提升RAG信赖度
人工智能·设计模式