setup-mcp

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Setting up MCP in a Plugin

在插件中配置MCP

MCP servers are configured via a
.mcp.json
file (dotfile) at the plugin root — not inside
.claude-plugin/
, and not
mcp.json
without the dot.
MCP服务器通过插件根目录下的
.mcp.json
文件(点文件)进行配置——不要放在
.claude-plugin/
目录内,也不要使用不带点的
mcp.json

File location

文件位置

plugins/<name>/
├── .claude-plugin/
│   └── plugin.json
├── .mcp.json        ← here
├── commands/
└── ...
plugins/<name>/
├── .claude-plugin/
│   └── plugin.json
├── .mcp.json        ← 在此处
├── commands/
└── ...

Schema

模式

json
{
  "<server-name>": {
    "type": "http",
    "url": "https://<endpoint>/mcp/",
    "headers": {
      "Authorization": "Bearer ${ENV_VAR}"
    }
  }
}
  • Top-level keys are the server names (used as identifiers in Claude Code)
  • type
    : transport type — use
    "http"
    for HTTP/SSE endpoints
  • url
    : the MCP server endpoint URL
  • headers
    : optional; use
    ${VAR}
    syntax for environment variable interpolation (e.g.,
    ${GITHUB_TOKEN}
    )
json
{
  "<server-name>": {
    "type": "http",
    "url": "https://<endpoint>/mcp/",
    "headers": {
      "Authorization": "Bearer ${ENV_VAR}"
    }
  }
}
  • 顶级键为服务器名称(在Claude Code中用作标识符)
  • type
    :传输类型——对于HTTP/SSE端点使用
    "http"
  • url
    :MCP服务器端点URL
  • headers
    :可选;使用
    ${VAR}
    语法进行环境变量插值(例如
    ${GITHUB_TOKEN}

Example (github plugin)

示例(github插件)

json
{
  "github": {
    "type": "http",
    "url": "https://githubcopilot-api.gsmlg.dev/mcp/",
    "headers": {
      "Authorization": "Bearer ${GITHUB_TOKEN}"
    }
  }
}
json
{
  "github": {
    "type": "http",
    "url": "https://githubcopilot-api.gsmlg.dev/mcp/",
    "headers": {
      "Authorization": "Bearer ${GITHUB_TOKEN}"
    }
  }
}

Notes

注意事项

  • Multiple servers can be registered in the same
    .mcp.json
    by adding more top-level keys
  • headers
    is only needed for authenticated endpoints
  • plugin.json
    does not carry MCP config — keep them separate
  • lspServers
    in
    plugin.json
    is for LSP (code intelligence), not MCP
  • 通过添加更多顶级键,可以在同一个
    .mcp.json
    中注册多个服务器
  • 仅在需要认证的端点时才需要
    headers
  • plugin.json
    包含MCP配置——请将它们分开存放
  • plugin.json
    中的
    lspServers
    用于LSP(代码智能),而非MCP