Repository navigation
fix(mcp): name the plugin path APM writes in .mcp.json conflict hints - #3930
Daniel Meppiel (danielmeppiel) merged 7 commits into
Conversation
The Claude/Copilot conflict hint classified APM's own
${CLAUDE_PROJECT_DIR:-.} plugin-root rendering as an apm.yml environment
reference, suggested ${CLAUDE_PROJECT_DIR} without its default, and asked
to rotate credentials for a path. Such a field now names the exact value
APM writes; real environment references keep their guidance.
Refs #3927
apm-spec-waiver: diagnostic wording only; no OpenAPM requirement changes
Co-authored-by: Copilot App <[email protected]>
…-conflict-hint-plugin-root
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Preserved-conflict hints can expose literal credentials and suggest incomplete or invalid JSON replacements for mixed fields and non-ASCII package paths.
3 open issues
What changed in this PR
Updates APM’s Claude and Copilot project .mcp.json conflict hints to distinguish plugin package paths from environment references. This addresses the guidance portion of #3927; the dependency-port identity issue remains separate.
Changes:
- Adds package-path recovery hints that preserve
${CLAUDE_PROJECT_DIR:-.}and avoid credential-rotation advice for path-only conflicts. - Adds unit and installed-CLI regression coverage, including preservation of conflicting native entries.
- Documents the revised guidance and records the user-visible change.
| File | Description |
|---|---|
tests/unit/test_claude_mcp.py |
Tests path-only and combined path/environment conflict guidance. |
tests/integration/test_lock_derived_expected_state_lifecycle.py |
Exercises conflict hints and native-file preservation for Claude and Copilot. |
src/apm_cli/adapters/client/claude.py |
Separates package-path hints from environment-reference guidance. |
docs/src/content/docs/consumer/install-mcp-servers.md |
Explains package-path restoration hints. |
CHANGELOG.md |
Records the conflict-guidance change under Unreleased. |
Review effort: Balanced
A plugin-root field can carry a literal credential (a query string) or a non-ASCII segment, and a mixed field also needs the project-root reference with its default. Print the exact value only for a plain ASCII path; otherwise name the reference verbatim, never the value. Addresses Copilot inline on src/apm_cli/adapters/client/claude.py:382-383. Co-authored-by: Copilot App <[email protected]>
A path inside a flag (--config=${CLAUDE_PROJECT_DIR:-.}/...) is printed
exactly when its literal text is plain, and a field that mixes the plugin
root with an env reference no longer lists the root as a reference
declared in apm.yml; it is named in the package-path clause instead.
Addresses cli-logging-expert panel findings 1 and 2.
Co-authored-by: Copilot App <[email protected]>
…-conflict-hint-plugin-root
The printability rule covers the whole field, so pin that literal text
before ${CLAUDE_PROJECT_DIR:-.} is never echoed either.
Addresses test-coverage-expert delta finding 1.
Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| CLI Logging Expert | 0 | 0 | 0 | Both prior findings resolved: flag-embedded plugin paths print verbatim, mixed fields list only env names. No new output issue; ship. |
| Test Coverage Expert | 0 | 1 | 0 | Mixed-field and in-flag root printing are trapped; the prefix gap it raised is folded in 8b19216. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 1 follow-ups
- [CLI Logging Expert] File a separate issue to fix the existing "references declared in apm.yml" wording so it covers env references declared by a package in plugin .mcp.json. -- It misattributes the source of a reference for plugin packages. It is out of scope for [BUG] Dependency identity key ignores the port; MCP conflict hint misreads ${CLAUDE_PROJECT_DIR:-.} #3927 per the record, but it is the same kind of trust gap.
Recommendation
Merge once a required review lands: CI is green on head 8b19216. The regression test fails on main and passes at head, every panel and Copilot finding was folded, and no blocking item remains. Track the "references declared in apm.yml" wording as a separate issue rather than widening this PR.
Folded in this run
- (Copilot) Do not echo a literal secret (e.g.
?token=) in a plugin-root field -- resolved in 0ede80a. - (Copilot) Keep the
:-.default and mention the package path for mixed fields -- resolved in 0ede80a. - (Copilot) Drop
ascii()escapes that are invalid JSON for non-ASCII paths -- resolved in 0ede80a. - (cli-logging-expert) Print a flag-embedded plugin path (
--config=${CLAUDE_PROJECT_DIR:-.}/...) exactly -- resolved in 63352ab. - (cli-logging-expert) Stop listing
${CLAUDE_PROJECT_DIR:-.}as an apm.yml reference in mixed fields -- resolved in 63352ab. - (test-coverage-expert) Pin that credential-shaped text before the root is never echoed -- resolved in 8b19216.
Copilot signals reviewed
src/apm_cli/adapters/client/claude.py:383-- LEGIT: a plugin-root field could carry a literal credential (resolved in 0ede80a).src/apm_cli/adapters/client/claude.py:382-- LEGIT: a mixed field dropped the path and the:-.default (resolved in 0ede80a).src/apm_cli/adapters/client/claude.py:383-- LEGIT:ascii()escapes are not valid JSON (resolved in 0ede80a).
Deferred (out-of-scope follow-ups)
- (cli-logging-expert) The "references declared in apm.yml" wording for env references declared by a package -- scope boundary: the record excludes other conflict-hint wording.
Regression-trap evidence (mutation-break gate)
tests/integration/test_lock_derived_expected_state_lifecycle.py::test_plugin_root_conflict_hint_restores_the_value_apm_writes[claude|copilot]-- with thesrc/fix reverted to main, both cases FAILED; with the fix, both passed.tests/unit/test_claude_mcp.py::TestClaudeLegacyEntries-- removed the root exclusion from the env-name scan: 3 tests FAILED. Replaced the printable check withstartswith(root): 2 FAILED. Replaced it with a suffix-only check: 1 FAILED. The guards were restored each time.
Lint contract
uvx [email protected] check and format --check (src, tests, scripts), pylint R0801 (10.00/10), scripts/lint-auth-signals.sh, and scripts/lint-architecture-boundaries.sh are all silent on HEAD merged with main bcd020f.
CI
All checks green on 8b19216: 31 pass, 3 skipped (after 0 CI fix iterations).
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3930 | 8b19216 |
ship_with_followups | 2 | 6 | 1 | 1 | green | MERGEABLE | BLOCKED | pending required review |
Full per-persona findings
CLI Logging Expert
Lean pass (0ede80a), both folded in 63352ab:
- [recommended] A plugin path inside a flag got the vague "a package path under" phrase, which drops the flag prefix, at
src/apm_cli/adapters/client/claude.py:389. - [recommended] The mixed-field hint listed
${CLAUDE_PROJECT_DIR:-.}under "references declared in apm.yml", atsrc/apm_cli/adapters/client/claude.py:405.
Delta pass (648b6dc): No findings.
Test Coverage Expert
Lean pass: No findings.
Delta pass (648b6dc), folded in 8b19216:
- [recommended] No test covered unprintable literal text before the plugin-root reference, so a suffix-only printability check would have passed, at
tests/unit/test_claude_mcp.py:631.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.


Description
Root cause 2 of #3927. When a Claude or Copilot project
.mcp.jsonentry for a plugin MCP server conflicts,ClaudeClientAdapter.native_conflict_guidance(inherited byCopilotProjectClientAdapter) treated APM's own${CLAUDE_PROJECT_DIR:-.}plugin-root rendering as anapm.ymlenvironment reference. The hint then told users to write${CLAUDE_PROJECT_DIR}(dropping the:-.default, which breaks the server) and to rotate credentials for a path.The adapter now strips its own
plugin_root_project_referencebefore collecting reference names:(args[0]: ${CLAUDE_PROJECT_DIR:-.}/apm_modules/_local/plug/scripts/server.js), or suggests renaming or removing the connection. No credential-rotation line.apm.ymlenvironment references keep today's names-only guidance and rotation line. If both kinds conflict, the package paths are appended to the same hint.Before (main 0e19cce):
After:
Issue and approved scope
Issue: Refs #3927
Human scope-approval comment: #3927 (comment)
Does this PR complete the issue, or what remains? It fixes root cause 2 (the conflict hint) only. Root cause 1 (the dependency identity key ignores the port) is handled in a separate PR.
Type of change
Testing
New tests:
tests/integration/test_lock_derived_expected_state_lifecycle.py::test_plugin_root_conflict_hint_restores_the_value_apm_writes[claude|copilot]: installed CLI, local plugin dependency, hand-edited.mcp.jsonarg. Fails on unfixed main for both targets and passes with the fix.tests/unit/test_claude_mcp.py:test_conflict_guidance_restores_plugin_root_path_without_rotationandtest_conflict_guidance_keeps_env_hint_beside_plugin_root_path. Both fail on main.Validation evidence (on HEAD merged with main 09af2b1):
APM_BINARY_PATH=.venv/bin/apm .venv/bin/python -m pytest -p no:xdist tests/integration/test_lock_derived_expected_state_lifecycle.py -k conflict_hintwith thesrc/fix reverted: 2 failed. With the fix: 2 passed.APM_BINARY_PATH=.venv/bin/apm .venv/bin/python -m pytest -p no:xdist tests/integration/test_claude_mcp_env_references_e2e.py tests/integration/test_lock_derived_expected_state_lifecycle.py: 15 passed..venv/bin/python -m pytest -p no:xdist tests/unit/test_claude_mcp.py tests/unit/integration -k "conflict or claude": 350 passed.uvx [email protected] checkanduvx [email protected] format --checkonsrc/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py: passed..venv/bin/python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/: 10.00/10.bash scripts/lint-auth-signals.sh: clean.bash scripts/lint-architecture-boundaries.sh: exit 0.Changelog
## [Unreleased]inCHANGELOG.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.Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.