---
title: "VS Code (GitHub Copilot) MCP 配置：文件路径、键和示例 · DotsAgent"
description: "从 Microsoft 向 VS Code (GitHub Copilot) 添加 MCP 服务器：了解配置文件位置、顶层键和格式、远程 OAuth 支持，以及配置示例。"
url: https://dotsagent.io/zh/mcp/clients/vscode-copilot
---

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) 配置 →](https://dotsagent.io/zh/mcp/config#client=vscode-copilot)

## 其他客户端

[Claude Desktop](https://dotsagent.io/zh/mcp/clients/claude-desktop)

[Claude Code](https://dotsagent.io/zh/mcp/clients/claude-code)

[Cursor](https://dotsagent.io/zh/mcp/clients/cursor)

[Windsurf / Devin Desktop](https://dotsagent.io/zh/mcp/clients/windsurf)

[Zed](https://dotsagent.io/zh/mcp/clients/zed)

[OpenAI Codex CLI](https://dotsagent.io/zh/mcp/clients/codex-cli)

[Gemini CLI](https://dotsagent.io/zh/mcp/clients/gemini-cli)

[ChatGPT](https://dotsagent.io/zh/mcp/clients/chatgpt)

[OpenClaw](https://dotsagent.io/zh/mcp/clients/openclaw)

[Cline](https://dotsagent.io/zh/mcp/clients/cline)

[Continue](https://dotsagent.io/zh/mcp/clients/continue)

[JetBrains AI Assistant](https://dotsagent.io/zh/mcp/clients/jetbrains-ai)

## 来源

1. [code.visualstudio.com](https://code.visualstudio.com/docs/copilot/reference/mcp-configuration)/docs/copilot/reference/mcp-configuration
2. [code.visualstudio.com](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)/docs/copilot/customization/mcp-servers

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

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