Claude Code中英文系列教程29:使用插件提供的 MCP 服务器

Plugins can bundle MCP servers, automatically providing tools and integrations when the plugin is enabled. Plugin MCP servers work identically to user-configured servers.

插件可以捆绑 MCP 服务器,在插件启用时自动提供工具和集成。插件 MCP 服务器与用户配置的服务器工作方式完全相同。

1, How plugin MCP servers work:

插件 MCP 服务器的工作原理:

Plugins define MCP servers in .mcp.json at the plugin root or inline in plugin.json

插件在插件根目录的 .mcp.json 处定义 MCP 服务器或直接在 plugin.json 处定义

When a plugin is enabled, its MCP servers start automatically

当插件启用时,其 MCP 服务器将自动启动

Plugin MCP tools appear alongside manually configured MCP tools

插件 MCP 工具与手动配置的 MCP 工具并列出现

Plugin servers are managed through plugin installation (not /mcp commands)

插件服务器通过插件安装进行管理(不是 /mcp 命令)

2,Example plugin MCP configuration:

插件 MCP 示例配置:

In .mcp.json at plugin root:

在插件根目录下的.mcp.json:

bash 复制代码
{
  "database-tools": {
    "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
    "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
    "env": {
      "DB_URL": "${DB_URL}"
    }
  }
}

Or inline in plugin.json:

或直接在 plugin.json 中:

bash 复制代码
{
  "name": "my-plugin",
  "mcpServers": {
    "plugin-api": {
      "command": "${CLAUDE_PLUGIN_ROOT}/servers/api-server",
      "args": ["--port", "8080"]
    }
  }
}

3,Plugin MCP features: 插件 MCP 功能:

Automatic lifecycle: Servers start when plugin enables, but you must restart Claude Code to apply MCP server changes (enabling or disabling)

自动生命周期:插件启用时服务器启动,但您必须重启 Claude Code 才能应用 MCP 服务器更改(启用或禁用)

Environment variables: Use ${CLAUDE_PLUGIN_ROOT} for plugin-relative paths

环境变量:使用 ${CLAUDE_PLUGIN_ROOT} 表示插件相对路径

User environment access: Access to same environment variables as manually configured servers

用户环境访问:可访问与手动配置的服务器相同的环境变量

Multiple transport types: Support stdio, SSE, and HTTP transports (transport support may vary by server)

多种传输类型:支持 stdio、SSE 和 HTTP 传输(传输支持可能因服务器而异)

4,Viewing plugin MCP servers:

查看插件 MCP 服务器:

bash 复制代码
# Within Claude Code, see all MCP servers including plugin ones
/mcp

Plugin servers appear in the list with indicators showing they come from plugins.

插件服务器会出现在列表中,并有指示器显示它们来自插件。

5,Benefits of plugin MCP servers:

插件 MCP 服务器的优势:

Bundled distribution: Tools and servers packaged together

捆绑分发:工具和服务器打包在一起

Automatic setup: No manual MCP configuration needed

自动设置:无需手动配置 MCP

Team consistency: Everyone gets the same tools when plugin is installed

团队一致性:插件安装后,每个人都会获得相同的工具

相关推荐
六边形工程师4 小时前
致敬,DeepSeek 最新开源的不是模型,是国产算力的地基
ai编程
全栈弄潮儿4 小时前
哪些任务该交给 AI,哪些必须由开发者负责?
aigc·openai·ai编程
stormzhangV4 小时前
A 社为什么反超了
人工智能·ai编程·claude
空心木偶☜7 小时前
LangGraph 错误处理和重试机制
ai·ai编程·langgraph
Maynor9969 小时前
让 AI 编程助手学会做视频、做 PPT:Agent Skills 入门与安装全指南
人工智能·aigc·ai编程·效率工具·cursor·claude code
猛犸象限9 小时前
【CJMP Grok Bot实践】从鸿蒙搬到 iOS 和 Android,我们为什么最后选了 CJMP
ai编程·grok
程序员老赵10 小时前
Docker 部署 DeepSeek Harness:轻松搭建局域网里的 AI Agent 平台
后端·ai编程·deepseek
mantou13210 小时前
我做了个 App:在手机上指挥电脑里的 Claude Code / Codex,还能直接看它产出的图表和模拟器画面
开源·ai编程·claude
王中阳Go10 小时前
自己摸了 2 个月零 offer,补底子只用了 3 块:Go 后端转 AI 最难的不是技术
后端·agent·ai编程
柯南466810 小时前
【AI工程师精讲】KV Cache 精讲:为什么 AI 越聊越慢,以及长上下文真正的成本在哪
人工智能·ai编程