Copilot MCP Tool 是一个开源的模型上下文协议(MCP)服务器,用于将你的 IDE 或 AI 助手(Claude、Cursor 等)连接到 GitHub Copilot CLI。
用途:它的目标是从支持 MCP 的编辑器中直接使用 GitHub Copilot CLI,以便高效地分析和编辑代码。
主要能力:
- 主要功能:从 MCP 客户端向 GitHub Copilot CLI 提问,并提供完整的工具管理。
- 高级功能:批量处理、代码审查和头脑风暴。
- 支持非交互式自动化、带权限的安全工具执行。
- 支持通过 @ 文件引用进行大规模代码分析。
- 面向可靠性和速度构建,可流式输出进度更新。
- 可与标准 MCP 客户端干净集成,用于代码审查、重构、文档编写和 CI 自动化。
使用方式:
- 前置要求:Node.js(v18.0.0 或更高版本)、GitHub Copilot CLI(必需)。
- 在 Claude Code 中输入 /mcp 可验证 Copilot MCP 是否已激活。
- 安装与配置:可将配置添加到 Claude Desktop 配置文件;推荐使用 NPX 方式,或使用全局安装配置。
- Claude Desktop 配置文件位置:macOS:~/Library/Application Support/Claude/claude_desktop_config.json;Windows:%APPDATA%\Claude\claude_desktop_config.json;Linux:~/.config/claude/claude_desktop_config.json。更新配置后需重启终端会话。
- 环境变量用于配置默认行为。可用模型包括:claude-sonnet-4.5(默认,最适合代码生成)、claude-sonnet-4(更快版本)、gpt-5(OpenAI GPT-5)。优先级:model 参数 > COPILOT_MODEL 环境变量 > Copilot CLI 默认值(claude-sonnet-4.5)。
- COPILOT_MCP_CWD 环境变量用于设置 Copilot CLI 命令执行的工作目录。解析优先级:请求中的 workingDir 参数(最高)> COPILOT_MCP_CWD 环境变量 > PWD 或 INIT_CWD 环境变量 > 从提示中的 @path 自动推断 > process.cwd()(最低)。IntelliJ IDEA / IDE 用户如果 Copilot CLI 找不到项目文件,可在 MCP 服务器配置中设置 COPILOT_MCP_CWD 指向项目目录。
- 示例工作流:自然语言指令如“use copilot to explain index.html”“understand this repo with @src”“look for vulnerabilities and suggest fixes”;在 Claude Code 中输入 /copilot 可访问 MCP 服务器工具。
- 文件引用(使用 @ 语法):例如 ask copilot to analyze @src/main.ts and explain what it does;use copilot to summarize @. the current directory;analyze @package.json and list dependencies using copilot。
- 一般问题(不带文件):例如 ask copilot to explain div centering;ask copilot about best practices for React development;use copilot for TypeScript debugging help。
- 高级示例:头脑风暴与构思,例如 brainstorm ways to optimize our CI/CD pipeline using SCAMPER method;use copilot to brainstorm 10 innovative features for our app;ask copilot to generate product ideas for the healthcare domain with design-thinking approach。
工具权限与安全:GitHub Copilot CLI 支持工具权限和目录访问控制。此服务器默认允许所有工具用于非交互模式。
提供给 AI 的工具:
- ask:执行 GitHub Copilot CLI,支持全面的工具和目录管理。支持 @ 文件引用以包含文件内容。工具权限:allowAllTools、allowTool、denyTool。目录访问:addDir 用于授予文件系统访问权限。高级选项:logLevel、resume(会话管理)、screenReader 支持。会话管理和日志控制。
- batch:在批量模式下使用 GitHub Copilot CLI 处理多个原子任务。支持并行或顺序执行。基于优先级的任务排序(high、normal、low)。全面的错误处理和进度报告。stop-on-error 或 continue-on-error 模式。详细的执行报告,包含计时和状态。
- review:使用 GitHub Copilot CLI 进行全面的代码审查。多种审查类型:security、performance、code-quality、best-practices、architecture、testing、documentation、accessibility、comprehensive。严重性过滤:low、medium、high、critical。输出格式:markdown、json、text。修复建议和优先级排序。文件模式排除和问题数量限制。
- brainstorm:使用结构化方法生成新颖想法。多种框架:divergent、convergent、SCAMPER、design-thinking、lateral。领域特定上下文(software、business、creative、research、product、marketing)。可配置的想法数量和分析深度。包含可行性、影响力和创新性评分。示例:brainstorm prompt:"ways to improve code review process" domain:"software" methodology:"scamper"。
- ping:简单的测试工具,回显消息,用于验证 MCP 连接是否工作。示例:/copilot:ping (MCP) "Hello from Copilot MCP!"。
- Help:显示 GitHub Copilot 的 CLI 帮助文本。自动检测可用的 CLI 工具。如果工具缺失则显示安装说明。
- version:显示所有 CLI 工具和 MCP 服务器的版本信息。报告 GitHub Copilot CLI、Node.js 和 MCP 服务器版本。包含缺失工具的安装命令。
- timeout-test:用于防止超时的测试工具。按指定时长(毫秒)运行。用于测试长时间运行的操作。
用户斜杠命令(可在 Claude Code 界面直接使用,其他客户端的兼容性尚未测试):
- /analyze:使用 Copilot 分析文件或目录,或提出一般问题。prompt(必需):分析提示。使用 @ 语法包含文件(例如 /analyze prompt:@src/ summarize this directory),或提出一般问题(例如 /analyze prompt:Please use a web search to find the latest news stories)。
- /review:使用 Copilot 执行全面代码审查。target(必需):要审查的文件/目录(例如 /review target:@src/ 或 /review target:@main.js)。reviewType(可选):审查类型 - security、performance、code-quality 等。
- /batch:在批量模式下处理多个任务。tasks(必需):要处理的任务数组。
- /help:显示可用工具的 CLI 帮助信息。
- /ping:测试与服务器的连接。message(可选):要回显的消息。
适用场景:代码审查、重构、文档编写、CI 自动化、批量处理、头脑风暴等。
限制与说明:这是非官方第三方工具,与 GitHub 或 Microsoft 无关联、无背书或赞助。使用前需确保已安装 Node.js(v18.0.0 或更高版本)和 GitHub Copilot CLI。此服务器默认允许所有工具用于非交互模式。斜杠命令与其他客户端的兼容性尚未测试。许可证:MIT License。