Skip to content

Fix apm install --global skipping MCP server installation#638

Open
sergio-sisternes-epam wants to merge 5 commits intomicrosoft:mainfrom
sergio-sisternes-epam:fix/637-global-mcp-install
Open

Fix apm install --global skipping MCP server installation#638
sergio-sisternes-epam wants to merge 5 commits intomicrosoft:mainfrom
sergio-sisternes-epam:fix/637-global-mcp-install

Conversation

@sergio-sisternes-epam
Copy link
Copy Markdown
Collaborator

Description

Add scope awareness to MCP server installation so that apm install --global writes MCP server entries to global/user-scoped runtime config paths (e.g. ~/.copilot/mcp-config.json for Copilot CLI) instead of unconditionally skipping all MCP installation at user scope.

Fixes #637

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Sergio Sisternes and others added 2 commits April 9, 2026 14:45
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the blanket should_install_mcp=False gate for InstallScope.USER
in install.py. Instead, add scope awareness to MCPClientAdapter via a
supports_user_scope class attribute that each adapter declares:

- CopilotClientAdapter: True (~/.copilot/mcp-config.json)
- CodexClientAdapter: True (~/.codex/config.toml)
- VSCodeClientAdapter: False (.vscode/mcp.json)
- CursorClientAdapter: False (.cursor/mcp.json)
- OpenCodeClientAdapter: False (opencode.json)

MCPIntegrator.install() and remove_stale() now accept a scope parameter
and filter target_runtimes to only global-capable adapters at USER scope.
The uninstall path (_cleanup_stale_mcp) also receives scope so global
uninstall only cleans global configs.

This also unblocks --trust-transitive-mcp at global scope, which was
silently ignored when the blanket MCP gate was active.

Fixes microsoft#637

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sergio-sisternes-epam sergio-sisternes-epam marked this pull request as ready for review April 9, 2026 13:58
Copilot AI review requested due to automatic review settings April 9, 2026 13:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes global-scope MCP installation so apm install --global installs MCP servers for runtimes that have user/global config paths (instead of blanket-skipping MCP at user scope), and threads scope through install/uninstall MCP cleanup.

Changes:

  • Add supports_user_scope to MCP client adapters and filter MCP install/cleanup targets based on InstallScope.
  • Remove the user-scope MCP blanket-disable in apm install and forward scope into MCP install/remove-stale paths.
  • Add unit tests plus doc/changelog updates describing the new --global MCP behavior.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/unit/test_global_mcp_scope.py Adds coverage for adapter scope flags, MCPIntegrator filtering, uninstall cleanup behavior, and install command integration.
src/apm_cli/integration/mcp_integrator.py Adds scope to install() / remove_stale() and filters runtimes at user scope using adapter capability.
src/apm_cli/commands/install.py Removes blanket user-scope MCP skip; forwards scope to MCPIntegrator install/remove_stale.
src/apm_cli/commands/uninstall/engine.py Threads scope through stale MCP cleanup to avoid touching workspace configs in user scope.
src/apm_cli/commands/uninstall/cli.py Passes uninstall scope into _cleanup_stale_mcp(...).
src/apm_cli/adapters/client/base.py Introduces supports_user_scope: bool = False default on MCP adapters.
src/apm_cli/adapters/client/copilot.py Marks Copilot adapter as user-scope-capable (supports_user_scope = True).
src/apm_cli/adapters/client/codex.py Marks Codex adapter as user-scope-capable (supports_user_scope = True).
src/apm_cli/adapters/client/cursor.py Explicitly marks Cursor as workspace-only (supports_user_scope = False).
src/apm_cli/adapters/client/opencode.py Explicitly marks OpenCode as workspace-only (supports_user_scope = False).
docs/src/content/docs/guides/dependencies.md Updates docs to reflect partial user-scope MCP support (global-capable runtimes only).
CHANGELOG.md Adds unreleased “Fixed” entries for global-scope MCP install and --trust-transitive-mcp behavior.

sergio-sisternes-epam and others added 2 commits April 9, 2026 16:33
- Wrap ClientFactory.create_client() in try/except ValueError in both
  install() and remove_stale() scope filtering so unsupported runtimes
  are silently skipped instead of crashing
- Replace brittle source-text assertion in TestInstallCommandMCPScope
  with a functional test that calls MCPIntegrator.install() with mocked
  dependencies and verifies scope filtering end-to-end
- Consolidate CHANGELOG into single entry referencing PR microsoft#638

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] apm install --global skips MCP server installation for all runtimes

2 participants