[PR #7453] fix(cli): reject surplus MCP registration arguments #7849

Open
opened 2026-11-05 01:48:06 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7453
Author: @Ha1baraA11
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: pr/rea-7375


📝 Commits (5)

  • da9ce70 fix(cli): reject surplus MCP registration arguments
  • 8ba00ea fix(cli): ignore help-shaped output values
  • 6a62399 Merge remote-tracking branch 'origin/main' into HEAD
  • 096e2cc fix(cli): keep mcp positional rejection single-response
  • 3ab1326 fix(cli): preserve mcp positional error output

📊 Changes

3 files changed (+251 additions, -4 deletions)

View changed files

📝 src/cli.ts (+15 -2)
📝 src/cli/strictPositionals.ts (+85 -2)
➕ tests/boundary/cli/mcpAddPositionals.test.ts (+151 -0)

📄 Description

Summary

rea mcp add rejects unexpected positional arguments before writing client configuration.
Related to #7375

Problem and expected behavior

  • The registered-command positional guard cannot see Incur's built-in mcp add route, which reaches the settings writer without rejecting its unbound positional tail.
  • docs/cli.md already requires surplus positionals to be rejected before execution; checking the built-in route at the outer CLI boundary restores that documented behavior without changing valid registration.

Change and scope

  • Check the built-in mcp add positional tail before Incur dispatches registration, returning a nonzero CLI error when extra arguments are present.
  • Add a CLI regression that verifies the rejected form leaves Amp settings absent and the valid form still writes the expected entry in an isolated home.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/cli/strictPositionals.ts, before Incur dispatches built-in mcp add to its Amp settings writer; src/cli.ts supplies the configured CLI name for the diagnostic.
  • Contribution scope fit and linked maintainer decision: routine correction to the existing CLI argument boundary; no new provider, target execution, or scope decision is involved.
  • CLI and MCP/tool-catalog contract: enforces the documented surplus-positionals rule for mcp add; no MCP tool schema, server protocol, or generated catalog changes.
  • Provider, bridge, target-format, or platform compatibility: valid Amp registration keeps its current settings shape; no analysis provider, bridge, or input format changes.
  • Evidence, artifact, provenance, or reconstruction contract: not applicable; no analysis Evidence or stored artifact is changed.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): no analysis target or external service is selected. The test writes and reads only under temporary homes; the configured node --version command is not executed.
  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.
  • Expected effects:
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/cli/mcpAddPositionals.test.ts, rejects surplus positional arguments to built-in MCP registration before writing configuration; it checks the JSON error, absence of a settings file for the rejected call, and the expected settings entry for a valid control.
  • Base reproduction or other evidence: on the Issue's source revision, the malformed command exited 0, reported successful Amp registration, and wrote the temporary settings file. The same named regression fails on the tested base at expect(invalid.exitCode).toBe(1) with actual 0.
  • User-visible CLI/MCP output (if applicable): {"code":"UNKNOWN","message":"Unexpected positional arguments: \"extra\". Use 'rea mcp add --help' for the declared argument shape."}.
  • Remaining proof gaps: the full aggregate suite, manual client interaction, and real MCP-client run were not performed. The change is limited to CLI argument admission; the regression exercises the actual source-level CLI and Amp config writer in isolated homes.
  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
  • For evidence-bearing changes: not applicable; this PR does not add or alter persisted analysis Evidence.
  • Boundary regressions: the CLI boundary regression covers rejection before registration and the valid registration control. Lifecycle regressions are not applicable because the guard runs before target/resource acquisition; the test directly verifies the rejected path creates no config file.

Validation performed

  • node scripts/run-exact-tests.mjs -t '^rejects surplus positional arguments to built-in MCP registration before writing configuration$' --reporter verbose tests/boundary/cli/mcpAddPositionals.test.ts — 1 passed.
  • npx --yes --package=node@24.22.1 --package=npm@11.16.0 -- npm ci — passed.
  • npx --yes --package=node@24.22.1 --package=npm@11.16.0 -- npm run test:focused -- src/ghidra/GhidraInstallation.test.ts — 113 passed.
  • npx --yes --package=node@24.22.1 --package=npm@11.16.0 -- npm run check:fast — passed.

Compatibility, safety, and release

  • The regression uses the source-level CLI with separate temporary homes. It stores node --version as test configuration data and does not start that command or an external MCP client.

Author readiness

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.
    Human owner: @Ha1baraA11

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/7453 **Author:** [@Ha1baraA11](https://github.com/Ha1baraA11) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/rea-7375` --- ### 📝 Commits (5) - [`da9ce70`](https://github.com/morluto/rea/commit/da9ce706190e63d437d99abb1bb77eb48d52fa9d) fix(cli): reject surplus MCP registration arguments - [`8ba00ea`](https://github.com/morluto/rea/commit/8ba00ea138d0e7aa9cafff055c96e89a8d478160) fix(cli): ignore help-shaped output values - [`6a62399`](https://github.com/morluto/rea/commit/6a6239905d3c4a7c63d783dacc813c31931dfab8) Merge remote-tracking branch 'origin/main' into HEAD - [`096e2cc`](https://github.com/morluto/rea/commit/096e2cce7f592feb2a34611af78883bc04b5918e) fix(cli): keep mcp positional rejection single-response - [`3ab1326`](https://github.com/morluto/rea/commit/3ab1326adecb82bdd8d2460396d787ef1f2b8e0c) fix(cli): preserve mcp positional error output ### 📊 Changes **3 files changed** (+251 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/cli.ts` (+15 -2) 📝 `src/cli/strictPositionals.ts` (+85 -2) ➕ `tests/boundary/cli/mcpAddPositionals.test.ts` (+151 -0) </details> ### 📄 Description ## Summary `rea mcp add` rejects unexpected positional arguments before writing client configuration. Related to #7375 ## Problem and expected behavior - The registered-command positional guard cannot see Incur's built-in `mcp add` route, which reaches the settings writer without rejecting its unbound positional tail. - `docs/cli.md` already requires surplus positionals to be rejected before execution; checking the built-in route at the outer CLI boundary restores that documented behavior without changing valid registration. ## Change and scope - Check the built-in `mcp add` positional tail before Incur dispatches registration, returning a nonzero CLI error when extra arguments are present. - Add a CLI regression that verifies the rejected form leaves Amp settings absent and the valid form still writes the expected entry in an isolated home. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/cli/strictPositionals.ts`, before Incur dispatches built-in `mcp add` to its Amp settings writer; `src/cli.ts` supplies the configured CLI name for the diagnostic. - Contribution scope fit and linked maintainer decision: routine correction to the existing CLI argument boundary; no new provider, target execution, or scope decision is involved. - CLI and MCP/tool-catalog contract: enforces the documented surplus-positionals rule for `mcp add`; no MCP tool schema, server protocol, or generated catalog changes. - Provider, bridge, target-format, or platform compatibility: valid Amp registration keeps its current settings shape; no analysis provider, bridge, or input format changes. - Evidence, artifact, provenance, or reconstruction contract: not applicable; no analysis Evidence or stored artifact is changed. - Target selection, authority, upstream behavior, and cleanup details (if applicable): no analysis target or external service is selected. The test writes and reads only under temporary homes; the configured `node --version` command is not executed. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [x] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. - Expected effects: - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none. ## Evidence and regression coverage - Tests added or updated: `tests/boundary/cli/mcpAddPositionals.test.ts`, `rejects surplus positional arguments to built-in MCP registration before writing configuration`; it checks the JSON error, absence of a settings file for the rejected call, and the expected settings entry for a valid control. - Base reproduction or other evidence: on the Issue's source revision, the malformed command exited 0, reported successful Amp registration, and wrote the temporary settings file. The same named regression fails on the tested base at `expect(invalid.exitCode).toBe(1)` with actual 0. - User-visible CLI/MCP output (if applicable): `{"code":"UNKNOWN","message":"Unexpected positional arguments: \"extra\". Use 'rea mcp add --help' for the declared argument shape."}`. - Remaining proof gaps: the full aggregate suite, manual client interaction, and real MCP-client run were not performed. The change is limited to CLI argument admission; the regression exercises the actual source-level CLI and Amp config writer in isolated homes. - [ ] Observed, derived, and inferred claims remain distinguishable. - [ ] Artifact identity, source provenance, and failed attempts remain preserved. - [ ] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. - For evidence-bearing changes: not applicable; this PR does not add or alter persisted analysis Evidence. - Boundary regressions: the CLI boundary regression covers rejection before registration and the valid registration control. Lifecycle regressions are not applicable because the guard runs before target/resource acquisition; the test directly verifies the rejected path creates no config file. ## Validation performed - `node scripts/run-exact-tests.mjs -t '^rejects surplus positional arguments to built-in MCP registration before writing configuration$' --reporter verbose tests/boundary/cli/mcpAddPositionals.test.ts` — 1 passed. - `npx --yes --package=node@24.22.1 --package=npm@11.16.0 -- npm ci` — passed. - `npx --yes --package=node@24.22.1 --package=npm@11.16.0 -- npm run test:focused -- src/ghidra/GhidraInstallation.test.ts` — 113 passed. - `npx --yes --package=node@24.22.1 --package=npm@11.16.0 -- npm run check:fast` — passed. ## Compatibility, safety, and release - The regression uses the source-level CLI with separate temporary homes. It stores `node --version` as test configuration data and does not start that command or an external MCP client. ## Author readiness - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. Human owner: @Ha1baraA11 ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7849
No description provided.