From 86ff9a541b60c07cea8a7ec45be9794ddd2ab424 Mon Sep 17 00:00:00 2001 From: pr-relay Date: Sun, 16 Aug 2026 15:31:44 +0000 Subject: [PATCH] Fix Copilot CLI project MCP config path --- src/apm_cli/adapters/client/copilot.py | 4 +++- src/apm_cli/integration/mcp_integrator.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/apm_cli/adapters/client/copilot.py b/src/apm_cli/adapters/client/copilot.py index e7db3a571..0d806a3d2 100644 --- a/src/apm_cli/adapters/client/copilot.py +++ b/src/apm_cli/adapters/client/copilot.py @@ -106,8 +106,10 @@ def get_config_path(self): """Get the path to the Copilot CLI MCP configuration file. Returns: - str: Path to ~/.copilot/mcp-config.json + str: Project .mcp.json or the user-scope ~/.copilot/mcp-config.json. """ + if not self.user_scope: + return str(self.project_root / ".mcp.json") copilot_dir = Path.home() / ".copilot" return str(copilot_dir / "mcp-config.json") diff --git a/src/apm_cli/integration/mcp_integrator.py b/src/apm_cli/integration/mcp_integrator.py index 24dd05aa8..5da264eb4 100644 --- a/src/apm_cli/integration/mcp_integrator.py +++ b/src/apm_cli/integration/mcp_integrator.py @@ -1103,6 +1103,20 @@ def _gate_project_scoped_runtimes( ) from apm_cli.integration.targets import RUNTIME_TO_CANONICAL_TARGET + # ``copilot`` is a user-facing target shared historically with the + # ``vscode`` alias. For an explicit project-scoped Copilot target, + # route the legacy VS Code runtime slot to the Copilot CLI adapter so + # MCP configuration lands in the CLI-supported project .mcp.json. + explicit_tokens = ( + [explicit_target] + if isinstance(explicit_target, str) + else list(explicit_target or []) + ) + if not user_scope and explicit_tokens == ["copilot"]: + target_runtimes = list(dict.fromkeys( + "copilot" if runtime == "vscode" else runtime for runtime in target_runtimes + )) + if target_decision is not None and target_decision.canonical_targets is not None: active = set(target_decision.canonical_targets) out = [