Copilot MCP Server
当使用这个技能时:
- 当你需要直接访问 Copilot AI模型来完成特定任务时
- 当你想使用 Copilot 的专业工具(审查,调试,解释等)时
- 当你需要在 copilot-flow工作流之外获得AI帮助时
可用MCP工具
核心工具
ask-copilot
用于编码帮助、调试和架构设计的通用AI助手。
mcp__plugin__copilot__ask-copilot(
prompt="string", // 必需:Copilot的问题或任务
context="string", // 可选:附加上下文
model="string", // 可选:使用特定模型(默认:claude-sonnet-4.5)
allowAllTools=true/false // 可选:允许Copilot使用所有可用工具
)
copilot-review
专注于特定领域的专业代码审查。
mcp__plugin__copilot__copilot-review(
code="string", // 必需:要审查的代码
focusAreas=["security", "performance", "maintainability", "best-practices"] // 可选:特别关注的领域
)
copilot-explain
获取代码片段的详细解释。
mcp__plugin__copilot__copilot-explain(
code="string", // 必需:要解释的代码
model="string" // 可选:使用的模型
)
copilot-debug
通过上下文感知分析调试代码中的错误。
mcp__plugin__copilot__copilot-debug(
code="string", // 必需:有错误的代码
error="string", // 必需:错误信息
context="string" // 可选:附加上下文
)
copilot-refactor
获取代码重构和改进的建议。
mcp__plugin__copilot__copilot-refactor(
code="string", // 必需:要重构的代码
goal="string" // 必需:重构目标(例如,"提高性能")
)
copilot-test-generate
为现有代码生成单元测试。
mcp__plugin__copilot__copilot-test-generate(
code="string", // 必需:要测试的代码
framework="string" // 可选:测试框架(例如,jest,pytest,mocha)
)
copilot-suggest
获取特定任务的CLI命令建议。
mcp__plugin__copilot__copilot-suggest(
task="string", // 必需:任务描述
model="string" // 可选:使用的模型
)
会话管理
copilot-session-start
开始一个新的会话,带有上下文跟踪。
mcp__plugin__copilot__copilot-session_start()
copilot-session-history
检索会话历史以保持连续性。
mcp__plugin__copilot__copilot-session_history(
sessionId="string" // 可选:特定会话ID
)
模型选择
根据任务复杂性选择可用模型:
claude-sonnet-4.5 (默认)
- 最适合:系统设计,架构决策,代码审查,性能优化
- 能力和速度的平衡
claude-opus-4.5
- 最适合:需要严格执行的复杂问题
- 最高的推理能力
claude-haiku-4.5
- 最适合:快速语法查询,简单的逻辑问题,API使用
- 最快的响应
gemini-3-pro-preview
- 最适合:Flutter,Angular,GCP,Firebase,Google Cloud开发
- Google生态系统专业化
gpt-5-mini (无限使用)
- 最适合:概念解释,一般技术问题,文档查询
- Pro+订阅者无使用限制
gpt-5.1-codex / gpt-5.1-codex-max
- 最适合:复杂算法,系统重构,大型功能开发
- 高级代码生成
gpt-5.2
- 最适合:具有大型上下文的复杂推理
- 最高的理解和领悟
使用示例
代码实现
mcp__plugin__copilot__ask-copilot(
prompt="实现一个用于用户认证的REST API端点,使用JWT",
model="claude-sonnet-4.5",
allowAllTools=true
)
安全审查
mcp__plugin__copilot__copilot_review(
code=`function login(username, password) {
const query = \`SELECT * FROM users WHERE username = '\${username}' AND password = '\${password}'\`;
return db.query(query);
}`,
focusAreas=["security", "sql-injection", "authentication"]
)
错误调试
mcp__plugin__copilot__copilot_debug(
code="const result = await fetchData().json;",
error="TypeError: fetchData(...).json is not a function",
context="尝试从API解析JSON响应"
)
测试生成
mcp__plugin__copilot__copilot_test_generate(
code=`function isPrime(n) {
if (n <= 1) return false;
for (let i = 2; i * i <= n; i++) {
if (n % i === 0) return false;
}
return true;
}`,
framework="jest"
)
最佳实践
应该
- 在提示中具体明确
- 提供可用的上下文
- 根据任务复杂性选择合适的模型
- 使用会话管理进行相关查询
- 专注于特定领域的审查
不应该
- 使用过于宽泛的提示,如"写代码"
- 对简单任务过度使用强大的模型
- 传递空参数
- 在没有重点的情况下对所有领域进行审查
- 在一个会话中混合不相关的查询
错误处理
如果MCP服务器不可用:
- 检查GitHub Copilot CLI认证
- 验证MCP服务器配置
- 重启Claude Code或您的MCP客户端
集成说明
- 此技能提供直接工具访问
- 对于结构化工作流,请使用copilot-flow-integration技能
- 所有工具需要活跃的GitHub Copilot订阅
- 使用计入Copilot API限制
关键词
copilot, mcp, ai, 代码审查,调试,测试,重构,github copilot, claude, gpt, gemini