Skip to content

fix(install): keep local-bundle MCP servers as recorded baseline - #3972

Closed
Daniel Meppiel (danielmeppiel) wants to merge 2 commits into
mainfrom
danielmeppiel-bundle-mcp-view-retire
Closed

Daniel Meppiel (danielmeppiel) wants to merge 2 commits into
mainfrom
danielmeppiel-bundle-mcp-view-retire

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

apm install <bundle> records a bundle's MCP servers with bundle:<owner> lock provenance, but CurrentMcpConfigView derived servers only from apm.yml and locked dependencies. Right after the install, apm audit --ci (config-consistency) and apm install --frozen failed with the server reported lock-only, and the next unrelated apm install (or apm uninstall) removed the server while keeping the bundle's files.

The view now owns this case:

  • CurrentMcpConfigView.derive keeps bundle-owned lock servers that no current declaration supersedes in configs/provenance and exposes them as bundle_owned.
  • run_mcp_integration and the uninstall MCP cleanup keep bundle_owned servers instead of treating them as stale.
  • mcp_package_owner maps a package named bundle:* to package:bundle:*, so a dependency cannot forge bundle ownership to make its server sticky.
  • bundle_mcp_owner_token is the single token writer, used by run_owned_mcp_integration; the mutation_writes.mcp_declaration_scope rule now fails if derive stops reading the baseline or another module spells the bundle: MCP token (LSP keeps its own namespace).

Issue and approved scope

Issue: Fixes #3955

Human scope-approval comment: #3955 (comment)

Completes the issue. Bundle format and bundle uninstall are out of scope.

Type of change

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

Testing

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

Validation evidence:

  • APM_BINARY_PATH=.venv/bin/apm APM_E2E_TESTS=1 pytest tests/integration/test_local_bundle_mcp_lifecycle.py -- failed on main at apm audit --ci (bundle-server: in lockfile but not in manifest (declared by bundle:mcppkg)); passes with this change (install, audit --ci, --frozen, unrelated install, plain install, unrelated uninstall).
  • pytest tests/unit/integration/test_mcp_config_view.py -- 83 passed.
  • pytest tests/unit -n 8 -- 28347 passed; 51 failures all in test_unix_installer_checksums.py, test_unix_install_ownership.py, test_windows_unit_diagnostics.py (subprocess timeouts on a loaded host; reproduce identically on unmodified main).
  • bash scripts/lint-architecture-boundaries.sh -- clean; mutating derive or reintroducing f"bundle:{owner}" in install/mcp/integration.py each fail the rule.
  • uvx [email protected] check / format --check (CI paths) -- clean; pylint R0801 -- 10.00/10; scripts/lint-auth-signals.sh -- clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md:
    user-visible effect first, 25 words or fewer, ending with (#PR);
    breaking changes only under upgrade notes; no Highlights; see
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

apm install <bundle> records its MCP servers with bundle:<owner>
provenance, but CurrentMcpConfigView only derived servers from apm.yml
and locked dependencies. audit --ci and install --frozen then reported
them as lock-only, and the next unrelated install or uninstall removed
them while keeping the bundle's files.

The view now keeps bundle-owned lock servers that no current declaration
supersedes in its configs and provenance (bundle_owned), install and
uninstall keep them, and a package cannot claim the bundle: owner
namespace. The declaration-scope architecture rule guards the owner.

Closes #3955

apm-spec-waiver: local-bundle MCP ownership bookkeeping only; no OpenAPM normative requirement changes

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 19, 2026
Copilot AI balanced review requested due to automatic review settings November 19, 2026 18:37
Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Active issues can delete a bundle’s native MCP server during runtime changes and cause frozen installs to reject valid escaped-owner servers on a cold cache.

2 open issues
What changed in this PR

This PR addresses #3955 by treating local-bundle MCP servers as recorded baseline configuration, so audit, frozen installs, and unrelated package operations recognize them.

Changes:

  • Retains bundle-owned servers in the MCP configuration view and install/uninstall reconciliation.
  • Centralizes bundle ownership tokens and prevents dependency names from claiming that namespace.
  • Adds regression coverage, architecture checks, and user-facing documentation.
File Description
tests/​unit/​integration/​test_mcp_config_view.py Tests bundle baselines, declaration precedence, and owner-token escaping.
tests/​integration/​test_local_bundle_mcp_lifecycle.py Tests audit, frozen installs, and unrelated package operations.
src/​apm_cli/​integration/​mcp_config_view.py Adds bundle baseline recognition and canonical ownership tokens.
src/​apm_cli/​install/​mcp/​integration.py Retains bundle server names during install reconciliation.
src/​apm_cli/​commands/​uninstall/​engine.py Includes bundle-owned servers in the retained server set.
scripts/​architecture_linter/​checks/​mutation_mcp_target_and_scope.py Guards baseline derivation and token ownership.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Documents bundle MCP persistence.
docs/​src/​content/​docs/​consumer/​deploy-a-bundle.md Explains audit and frozen-install acceptance.
CHANGELOG.md Records the user-visible fix.

Review effort: Balanced

raise
conflict = exc
new_mcp_servers = MCPIntegrator.get_server_names(mcp_deps)
new_mcp_servers = MCPIntegrator.get_server_names(mcp_deps) | bundle_owned
"""
return next((name for name in names if name), package_dir.name)
owner = next((name for name in names if name), package_dir.name)
return f"package:{owner}" if owner.startswith(BUNDLE_MCP_OWNER_PREFIX) else owner
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Superseded by #3989 (the #3983 umbrella, PR B, stacked on #3988). This branch's fix and tests were harvested into #3989, which routes the change through its canonical owner with a closed-world guard. Closing in favour of #3989.

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] MCP servers from a local bundle are invisible to the MCP view: audit and --frozen fail, and the next install removes them

2 participants