Repository navigation
Description
Describe the bug
When a user-scope MCP server is installed under a name that one target's config already holds with another
definition, and another target does not hold the name yet, apm install -g --mcp writes the new definition only to
the target that lacks it and leaves the existing entry in the other one. The lockfile nevertheless records the new
definition in mcp_configs and claims the name for both targets in mcp_target_servers. From then on:
--forceandapm install -g --frozenreport "already configured" / "All servers up to date" and change nothing,
so the two runtimes stay divergent (Claude Code talks to one server, Codex CLI to another, under the same name);- removing the entry from
apm.ymland runningapm install -gdeletes the other target's entry, which apm never
wrote ("Removed stale MCP server 'notes' from ~/.claude.json").
The same divergence follows when the existing entry was deployed by a package installed earlier for a subset of the
targets (a package declaring notes, installed with -t claude, then apm install -g -t claude,codex --mcp notes --url ...): Claude keeps the package's definition, Codex gets the root's, the lock claims the root's for both.
From the 0.33.0 source this looks like the combination of:
MCPIntegrator._check_self_defined_servers_needing_installationreturning a server when it is missing from at least
one runtime;MCPIntegrator._detect_mcp_config_driftcomparing the manifest's config with the lockfile's stored config only,
never with what a runtime's config actually holds (so a name already present everywhere with a foreign value is
"already configured" when the lock agrees with the manifest);_install_for_runtime(..., replace_existing=is_update)withis_updatefalse keeping the existing entry in a
runtime that already holds the name, while_record_managed_serverrecords ownership for every runtime that
"succeeded".
To Reproduce
Self-contained, in a throwaway HOME (no marketplace needed):
export HOME="$(mktemp -d)"; cd "$HOME"
printf '%s\n' '{"mcpServers": {"notes": {"type": "http", "url": "http://127.0.0.1:9/someone-else"}}}' > ~/.claude.json
apm install -g -t claude,codex --mcp notes --url http://127.0.0.1:8000/notes # exit 0
apm install -g -t claude,codex --mcp notes --url http://127.0.0.1:8000/notes --force # "already configured"
apm install -g --frozen # exit 0After each of the three commands:
~/.claude.json mcpServers.notes: {'type': 'http', 'url': 'http://127.0.0.1:9/someone-else'}
~/.codex/config.toml:
[mcp_servers.notes]
url = "http://127.0.0.1:8000/notes"
id = ""
and ~/.apm/apm.lock.yaml:
mcp_servers:
- notes
mcp_configs:
notes:
name: notes
transport: http
registry: false
url: http://127.0.0.1:8000/notes
mcp_target_servers:
claude:
- notes
codex:
- notesThen remove the notes entry from ~/.apm/apm.yml (dependencies.mcp: []) and run apm install -g:
[i] Removed stale MCP server 'notes' from ~/.claude.json
[+] Removed stale MCP server 'notes' from Codex CLI config
and ~/.claude.json's mcpServers is {}: the pre-existing entry is gone.
Expected behavior
One of, consistently across runtimes:
- treat a same-named entry whose value differs from the rendered definition as drift and replace it in every target
(the lock then truthfully records ownership), or - refuse (or warn and skip) the targets whose existing entry differs, and record ownership only for the targets apm
actually wrote, so a later removal never deletes an entry apm did not write.
--force in particular would be expected to make the targets match the manifest.
Environment (please complete the following information):
- OS: macOS 27 (arm64)
- Python Version: 3.14 (Homebrew's apm keg)
- APM Version: 0.33.0 (92b8ea8ebd)
- VSCode Version (if relevant): n/a
Logs
The first install's own output (HOME path elided) says it skipped Claude, then reports Claude as configured:
+- MCP Servers (1)
[i] Targeting specific runtimes: claude, codex
| [>] notes (self-defined, http)
| +- Configuring for Claude, Codex...
notes already configured, skipping
[*] Configured MCP server 'notes' for Codex CLI
+ notes
| [+] notes -> Claude, Codex (configured)
[*] Configured 1 server
[+] Added MCP server 'notes'
Additional context
Found while registering one loopback MCP server for both Claude Code and Codex in an environment where an agent or a
person may already have added a same-named server to ~/.claude.json. Workaround used: detect the divergence by
reading both configs, then drop the name from dependencies.mcp, run apm install -g --only mcp (which removes the
name from every target by name) and install it again.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
danielmeppiel commentedon Oct 20, 2026
Decision: approve
Area: project
Scope: For #3239, reproduce the reported Claude/Codex MCP connection collisions on current source and repair the remaining native-configuration comparison, truthful target reporting and ownership-safe lifecycle behavior. Preserve the actual-write ownership tracking already delivered by #3100. Through existing rendering and ownership owners, distinguish the requested configuration, unchanged APM-managed configuration, and foreign or user-modified same-name configuration. Update unchanged APM-managed connections normally, including the reported package-to-root override across an existing and newly selected target. Preserve conflicting user connections and report the requested installation as incomplete rather than fully configured.
Done when: A differing foreign or user-modified same-name connection is left untouched, the affected target is identified, and the unresolved requested-target conflict produces a nonzero result. Any successful nonconflicting writes are accurately recorded per target; presence or a successful skip alone never creates ownership. Removal preserves native entries that do not match a trustworthy managed baseline, including the reported historical false-ownership shape; ambiguous history gets actionable reconciliation rather than guessed adoption or deletion. Generic --force gains no automatic MCP takeover right, and frozen replay neither silently certifies conflicting native state nor rewrites lock intent. Installed-CLI lifecycle coverage with isolated state proves the Claude/Codex examples in supported project/user scopes, differing and identical foreign entries, managed package-to-root updates, repeat installs, force, frozen replay, prune/uninstall, target narrowing and historical claims, while preserving existing Cursor/OpenCode controls. Assert native configuration bytes and per-target ownership, not just exit codes; preserve unrelated settings, native schemas and existing safety checks. Update directly related guidance with understandable conflict-resolution examples. If a reported slice is already fixed, document the current evidence rather than reimplement it.
Out of scope: Automatic takeover of user connections, new overwrite/adoption flags, generic transaction or ownership redesign, whole-command rollback promises, universal historical ownership recovery, changing the data held by MCP services, registry identity redesign, unrelated MCP features or other issue scopes, assignment, release commitments, technical PR approval or merge, implementation dispatch or restarting blocked delivery.
Review contact: Daniel Meppiel (@danielmeppiel)
danielmeppiel commentedon Oct 20, 2026
Accepted for the remaining collision and connection-ownership repair, after reconciling changes already on main.
An example of the intended behavior: Alice manually connected Claude to her personal notes and called the connection
notes. A company package asks APM to add a differentnotesconnection to Claude and Codex. APM must not claim both are configured when Claude still points to personal notes. It should preserve that connection, clearly report the Claude conflict, and accurately record any company connection it did install for Codex. Later removal of the company package must not delete Alice's personal connection settings.This concerns the connection configuration, not deleting notes or data held by the service. Alice may need to rename or remove the conflicting connection herself. A generic
--forceretry is not new permission for APM to take it over.The complementary case matters too: when APM previously installed the company connection and the user has not modified it, an ordinary company-package update should update that connection normally. Protecting user settings must not turn routine APM-managed updates into manual work.
Current main
53ccf06d11dd2d675e8ea8c3e2523a6d321c1b79already includes #3100's shared change to record ownership only after actual writes, with Cursor/OpenCode lifecycle coverage. That delivered work is preserved, not reapproved or redone. The remaining source still has name-presence checks, manifest-versus-lock drift comparison, and successful-target reporting that warrant reproducing the full Claude/Codex path. Older incorrect ownership records also need conservative handling rather than blindly deleting a conflicting entry. This decision session inspected current source, the complete issue and existing tests; it did not independently run the reproduction.The accepted tradeoff is a visible incomplete-install result instead of a misleading green result or silent replacement. Successfully written nonconflicting targets can remain, with truthful ownership; this is not a new whole-command transaction. The strict scope record carries the complete acceptance criteria and exclusions. The issue stays open, with no assignment, release promise, PR approval or delivery dispatch.
Disclosure: GitHub Copilot prepared and posted this record after Daniel Meppiel explicitly accepted the complete behavior following a plain-language, example-led explanation.
wip: checkpoint unvalidated native MCP collision repair
test: guard MCP collision ownership and document recovery
fix(mcp): report same-name MCP conflicts on every JSON adapter (#3681)
fix: 0.36.0 red-team round 2 (MCP config safety, user-file collisions…