github / github/copilot-cli

Add --no-mcp-auto-discover flag to disable automatic .mcp.json discovery

未关闭
#3,419 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
area:configuration area:mcp area:non-interactive
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

When running Copilot CLI in headless/automated scenarios (e.g., as a bot backend, CI pipeline, or background service), the CLI auto-discovers `.mcp.json` from the workspace root and loads all MCP servers defined there. Some MCP servers (e.g., GenevaMonitoring) require interactive browser authentication and will hang or fail in headless environments. There's currently no way to prevent auto-discovery — you can only add more servers via `--additional-mcp-config`, not exclude the auto-discovered ones.

Proposed solution
Add a flag like --no-mcp-auto-discover (or --mcp-config-only) that disables automatic loading of .mcp.json from the workspace root. When used with --additional-mcp-config, it gives full control over exactly which MCP servers are loaded — essential for headless automation.

# Only load the explicitly specified MCP config, skip .mcp.json auto-discovery
copilot --no-mcp-auto-discover --additional-mcp-config "@.copilot-mcp-enrichment.json" -p "..."

Example prompts or workflows
1. Bot running Copilot CLI as subprocess for ICM incident enrichment — needs kusto + icm MCPs only, must avoid any server requiring interactive auth.
2. CI pipeline using Copilot CLI for automated code review — needs only ado MCP, repo's .mcp.json has servers that need credentials unavailable in CI.
3. Scheduled background tasks using Copilot CLI — any MCP server that triggers browser auth will hang the process indefinitely.
4. Multi-purpose repos where .mcp.json is configured for interactive developer use but automated tooling needs a subset.

Additional context

- Currently the only workaround is modifying .mcp.json locally (causes git conflicts on pull) or using git update-index --assume-unchanged (fragile)
- The --additional-mcp-config flag already exists for adding servers — this is the complementary "opt-out" counterpart
- .vscode/mcp.json serves interactive VS Code users; .mcp.json is for CLI — but there's no way to differentiate headless CLI from interactive CLI usage
- Version: Copilot CLI v1.0.49

贡献指南

打开贡献指南

调研方向

Start with the existing --additional-mcp-config handling and the automatic .mcp.json discovery path. Compare this with .vscode/mcp.json, which is intended for interactive VS Code users. Done means a new opt-out flag prevents loading the workspace .mcp.json while still allowing explicitly supplied MCP configuration, including in headless workflows.

由索引模型根据 Issue 内容生成。

评估

技术栈
shell
领域
cli
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。