dotsagent.io
语言:简体中文
Microsoft

向 VS Code (GitHub Copilot) 添加 MCP 服务器

VS Code 会读取工作区中的 .vscode/mcp.json、用户配置文件中的 mcp.json,或较新的可移植 .mcp.json 文件。

macOS
User profile mcp.json (open via 'MCP: Open User Configuration'); portable: ~/.copilot/mcp-config.json
Windows
User profile mcp.json (open via 'MCP: Open User Configuration'); portable: ~/.copilot/mcp-config.json
Linux
User profile mcp.json (open via 'MCP: Open User Configuration'); portable: ~/.copilot/mcp-config.json
项目文件
.vscode/mcp.json (key 'servers') or portable .mcp.json (key 'mcpServers')
顶层键
servers
格式
json
远程服务器的 OAuth
是

配置示例

此示例按该客户端所需的格式,添加 GitHub 托管的服务器和作为本地服务器的 Playwright。

.vscode/mcp.json
{
  "servers": {
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/"
    },
    "playwright": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "@playwright/mcp@latest"
      ]
    }
  }
}
shell
code --add-mcp '{"name":"github","type":"http","url":"https://api.githubcopilot.com/mcp/"}'
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'

注意事项和特殊情况

  • .vscode/mcp.json 使用 servers 键;可移植 .mcp.json 和 ~/.copilot/mcp-config.json 使用 mcpServers。
  • 顶层 inputs 数组会提示你输入密钥,避免将密钥写入文件。
  • 现在,引导式的“添加服务器”流程会提示 .vscode/mcp.json 和用户配置文件已弃用,建议改用可移植文件。两种旧配置仍可使用。
  • VS Code 也会自动发现已为 Claude Desktop、Copilot CLI、Cursor 和 Windsurf 配置的服务器。
  • code --add-mcp 可通过 JSON 字符串添加服务器。

生成 VS Code (GitHub Copilot) 配置 →

其他客户端

来源

  1. code.visualstudio.com/docs/copilot/reference/mcp-configuration
  2. code.visualstudio.com/docs/copilot/customization/mcp-servers

为 AI agent 开发者提供的独立参考资料。与此处提及的任何厂商均无关联。

© 2026 DotsAgent · 事实核查日期:2026年10月1日