Repository navigation
feat(cli): derive apm mcp install forwarded options from apm install - #3633
Daniel Meppiel (danielmeppiel) merged 5 commits into
Conversation
apm mcp install now declares the install options it forwards as real Click options cloned from the apm install command, so help text, validation and shell completion come from one definition. Raw values are re-emitted to apm install unchanged. Fixes #3588 Co-authored-by: Copilot App <[email protected]>
…meppiel-mcp-install-help-forwarded-options
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The alias parser can mistake a pass-through option’s flag-shaped value for its own flag, leaving --root without a value and breaking an otherwise valid install command.
1 open issue
What changed in this PR
This PR makes apm mcp install borrow option definitions from apm install, addressing #3588 by sharing help text, validation, and shell completion.
Changes:
- Lazily clones selected install options and reconstructs explicitly supplied values for forwarding.
- Adds regression coverage for help consistency, forwarding, validation, and completion.
- Updates the CLI reference, usage guide, and changelog.
| File | Description |
|---|---|
src/apm_cli/commands/mcp.py |
Adds borrowed option definitions, grouped help, and argument reconstruction. |
tests/unit/test_mcp_command.py |
Tests borrowed options, raw forwarding, validation, and completion. |
tests/unit/test_cli_consistency.py |
Compares forwarded help against canonical install definitions. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Updates the forwarded flag list and shared-help description. |
docs/src/content/docs/reference/cli/mcp.md |
Replaces duplicated descriptions with a link to install documentation. |
CHANGELOG.md |
Records the shared option help and completion changes. |
Review effort: Balanced
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| DevX UX Expert | 0 | 1 | 0 | Solid alias UX; forwarded help inherits '(requires --mcp)' which misleads in the alias context where --mcp is implicit. |
| Test Coverage Expert | 0 | 0 | 0 | All 5 user-promise surfaces (help drift, completion, validation, raw forwarding, e2e path) defended by regression traps; 17/17 passed. |
| Python Architect | 0 | 1 | 0 | Design is sound: selection-only coupling, lazy load, raw re-emission minimise Click-internals surface; tests pin the borrowing contract. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 2 follow-ups
- [DevX UX Expert] Add a note to the mcp install command description that '--mcp NAME' is implied, so the inherited '(requires --mcp)' parenthetical reads correctly in context. -- Stripping the parenthetical from cloned help would fork the strings and re-create drift; a command-level note preserves single-source identity.
- [Python Architect] Extract the copy + class swap into a _ForwardedInstallOption.from_install_option classmethod with a docstring warning about the init-bypass path. -- Makes the construction path discoverable and self-documenting; zero behaviour change.
Recommendation
Merge when CI is green. Both follow-ups are small and inside this PR's scope, so the merge worker folds them here rather than tracking them separately. The UX note is the higher-signal item; it is the only thing a user might notice in --help output.
Full per-persona findings
DevX UX Expert
- [recommended] Forwarded help strings show '(requires --mcp)' inside
apm mcp install --help, confusing users who are already in the --mcp context atsrc/apm_cli/commands/mcp.py:171
Options like --transport, --url, --env, and --header carry '(requires --mcp)'. Inapm mcp install, --mcp is implicit. Seeing it makes users wonder whether they must also pass --mcp.
Suggested: adapt the display to the alias context. The CEO resolved this as a command-description note so the shared strings stay identical.
Test Coverage Expert
No findings.
Python Architect
- [recommended] Extract the copy + class swap into a _ForwardedInstallOption classmethod so the init-bypass construction path is discoverable at
src/apm_cli/commands/mcp.py:159
copy.copy + class reassignment is the least-coupled option, but it silently bypasses init. A classmethod factory encapsulates the unusual construction and gives a docstring site for the warning.
Suggested:_ForwardedInstallOption.from_install_option(source)returning the clone with expose_value=False.
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-review-worker. This comment is AI-generated and may contain errors.
Borrow every apm install option (except the alias-owned --mcp) so Click parses pass-through values with install's own arity; only the 14 shown options appear in help and completion, the rest are hidden. A value like '--root --dry-run' now stays attached to its option, as in apm install (addresses Copilot inline on src/apm_cli/commands/mcp.py:235). Also folds panel follow-ups: a from_install_option factory documents the init-bypassing clone (python-architect), and the help states that '--mcp NAME' is implied so inherited '(requires --mcp)' notes read correctly without forking install's help strings (devx-ux-expert). Co-authored-by: Copilot App <[email protected]>
…meppiel-mcp-install-help-forwarded-options
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | Delta auto-borrowing of install options is architecturally sound: pure callback, COMMANDLINE-only forwarding, nargs guard in factory, set-equality test catches drift. |
| DevX UX Expert | 0 | 0 | 0 | Delta resolves prior '(requires --mcp)' finding with a contextual help note; hidden options error only on flags the user typed, no UX regression. |
| Test Coverage Expert | 0 | 0 | 0 | All delta tests pass. Flag-shaped-value, hidden-forward, borrowed-set, and help-note promises are mutation-verified regression traps. No silent-drift gap. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
Every follow-up from the lean panel is folded. The flag-value parsing bug is fixed and covered by regression tests. Three independent delta panelists returned zero findings. CI is green on e25cc28. Merge once the CODEOWNER approves. No follow-ups remain.
Full per-persona findings
Python Architect
No findings.
DevX UX Expert
No findings.
Test Coverage Expert
No findings.
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-review-worker. This comment is AI-generated and may contain errors.
Resolve conflicts with #3633 (forwarded apm install options) and #3630 (bootstrap author), keeping the APM_HOME wording. Co-authored-by: Copilot App <[email protected]>
* fix(tests): restore release-gate lanes for 0.36.0 Main's tag-gate lanes (build-release push + manual-build-release) were red on runs 43381609442, 43381682871 and 43394173235. PR CI never runs them. Product regressions (Windows/real installs), fixed: - Hook cleanup removed nothing on Windows: remove_stale_deployed_files looked up recorded hashes with POSIX keys while callers passed native backslash keys, so content proof failed closed (#3672, Refs #3649). - describe_path_obstruction returned None on Windows, which reports a directory-for-file as EACCES and a file-for-parent as ENOENT instead of EISDIR/ENOTDIR (#3709, Refs #3678). - Skill preflight refused claimed members of an unclaimed, populated skill directory that materialization leaves alone, failing a local bundle install (Refs #3625). Stale tests (behaviour changed intentionally), updated: - policy chain mocks now return real PolicyFetchResult (#2933, Refs #2753) - bare-cache/downloader/anonymous-https fixtures use real Git checkouts (#3603, Refs #3457) - mcp install help, registry error wording, deps why -g help (#3633 Refs #3588, #2803 Refs #2478, #3614 Refs #2884) - downloader stub carries carried_licenses (#3646, Refs #3556) - frozen-hash lifecycle uses a generic git host so -g URL validation uses git ls-remote instead of a live api.github.com 404 (#3672) New Windows-shaped regression tests are marked windows_compat. Co-authored-by: Copilot App <[email protected]> * chore: spec waiver for release-gate repair apm-spec-waiver: restores pre-existing behaviour on Windows and in skill preflight; no OpenAPM-observable change Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>

Description
TL;DR
apm mcp install --helpnow lists the options it forwards toapm installas real Click options, cloned fromapm install's own definitions. Help text, accepted values and shell completion come from one source and cannot drift. Forwarded installs behave as before: raw values are re-emitted toapm installunchanged.Fixes #3588
Note
Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.
Problem (WHY)
help=string ofapm mcp install(src/apm_cli/commands/mcp.py), not Click options, so they were not shell-completable.-t/--targetread "Agent target(s) to deploy to" whileapm installsays "Target harness(es) to deploy to" ([cli-consistency] CLI Consistency Report — 2026-11-11 #3554).--targetand--trust-transitive-mcp.The issue states the goal: help text, validation and shell completion should "stay in sync with
apm installautomatically". The repo's architecture rule says call sites should route "THROUGH that owner instead of re-deriving the answer locally" (.github/instructions/architecture.instructions.md).Approach (WHAT)
mcp installuses aclick.Commandsubclass that clones the selectedapm installOptionobjects on first use. Help, type, choices and metavar all come fromapm install.apm installas--flag valuebefore any--separator. Defaults are never materialised.apm installoption (except the alias-owned--mcp) is borrowed hidden: Click parses it with install's own arity and forwards it raw, so a value like--root --dry-runstays attached. The help notes that--mcp NAMEis implied.apm install's ownget_help_record.Implementation (HOW)
src/apm_cli/commands/mcp.py:_FORWARDED_INSTALL_PARAMSholds only the shown selection (install parameter names)._borrow_install_options()lazily clones every install option through_ForwardedInstallOption.from_install_optionand hides the unselected ones. It clones them fromapm_cli.commands.install.install, soapmstartup keepsinstalllazily imported (verified:apm mcp --helpdoes not import it)._ForwardedInstallOption.consume_valuecaptures the raw value when the source isCOMMANDLINE, andto_install_argsrebuilds the tokens.expose_value=Falsekeeps converted values out of the callback.tests/unit/test_cli_consistency.py: the FU-3 test now compares each forwarded flag's install help record, with whitespace removed, against the "Forwarded install options" section.tests/unit/test_mcp_command.py: adds tests for borrowed definitions, verbatim raw forwarding (-t a,b,-g, repeated--env, pass-through--runtime,--tail), install-identical validation errors, and shell completion of names and choices.reference/cli/mcp.mdreplaces the copied table with the flag list and a link toapm install.apm-guidecommands.mdlists the full forwarded set.Diagrams
How a forwarded flag gets from
apm mcp installtoapm install(new parts boxed):flowchart LR U["apm mcp install api -t claude --env A=1 -- npx srv"] --> P["Click parse with borrowed install options"] subgraph NEW["New in this PR"] B["_borrow_install_options: clone apm install Options"] --> P P --> R["consume_value records raw value"] R --> T["to_install_args rebuilds tokens"] end T --> F["apm install --mcp api --target claude --env A=1 -- npx srv"]Trade-offs
mcp.py. Which install options to surface is a product choice. It is kept to the 14 flags the old help and the issue name, because new flags are out of scope. The definitions are never copied, and the test fails ifapm installdrops or rewords one.clone.__class__ = _ForwardedInstallOption) instead of rebuilding eachOptionfrom attributes. The subclass adds no state, and rebuilding would mean another hand-maintained attribute list.TargetParamTypenormalises values, so re-emitting the raw token keepsapm installbehaviour unchanged. Short flags are forwarded in their long form (-gbecomes--global);apm installtreats both spellings the same.Benefits
apm mcp installfor the 14 forwarded options and their choices (for example--transport <TAB>).--targetwording drift from [cli-consistency] CLI Consistency Report — 2026-11-11 #3554 is fixed by construction.--transport bogus, fail atapm mcp installwith the same Click error asapm install.apm install. All 4 mutation checks below fail the suite.Validation
Targeted tests (after merging current main)
Red before the fix:
5 failed, 12 passed(the new tests plus the rewritten FU-3 test).Mutation-break checks (each restored after)
verbosefrom the forwarded selection--targethelp with the old proseclick.Option(no subclass)Lint mirror (CI-equivalent)
Manual end-to-end
Scenario evidence
test_cli_consistency.py::test_mcp_install_help_forwarded_options_complete--)test_mcp_command.py::TestMcpInstallAlias::test_forwards_raw_option_values_verbatim,::test_pass_through_value_shaped_like_a_flag_stays_attached,::test_hidden_install_options_forward_but_stay_out_of_helpand the existing alias testsTestMcpInstallAlias::test_forwarded_option_validation_matches_installTestMcpInstallAlias::test_forwarded_options_shell_completeHow to test
apm mcp install --help: see the "Forwarded install options" section, worded exactly likeapm install --help.apm mcp install fetch --dry-run -t copilot -- npx -y srv: dry-run add succeeds.apm mcp install fetch --transport bogus: Click choice error, exit 2.apm mcp install x --transport <TAB>offers the four transports.Issue and approved scope
Issue: Fixes #3588
Human scope-approval comment: #3588 (comment) (review contact Daniel Meppiel (@danielmeppiel))
This PR completes the issue: real options with help from the shared definitions, shell completion, a drift test, unchanged forwarding behaviour, and updated CLI reference plus apm-guide
commands.md. No new flags, renames,apm installchanges or other aliases.Type of change
Testing
Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedCo-authored-by: Copilot [email protected]