Skip to content

fix(cli): reject surplus MCP registration arguments - #7453

Closed
Ha1baraA11 wants to merge 7 commits into
morluto:mainfrom
Ha1baraA11:pr/rea-7375
Closed

Ha1baraA11 wants to merge 7 commits into
morluto:mainfrom
Ha1baraA11:pr/rea-7375

Conversation

@Ha1baraA11

Copy link
Copy Markdown
Contributor

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

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-27T04:38:35.727460Z
We couldn’t complete this review. Comment @codex review to try again.
da9ce70 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The reviewed changes appear safe to merge, with no new blocking issue established.

Summary

Adds an early check for extra mcp add arguments before registration can write client settings.

  • Extra words on rea mcp add are rejected before settings are written.
  • JavaScript analysis keeps the same behavior with grouped state imports.

No new actionable findings were established. The previous threads were unnumbered, so they have no numbered ledger entries. Ha1baraA11 manually resolved the earlier help-text thread without an explanatory reply.

Tests were not run during this review; dependencies were not installed. GitHub replacement status could not be checked because authentication was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[CLI arguments] --> B{Output controls valid?}
  B -->|No| C[Report output error]
  B -->|Yes| D{Extra mcp add arguments?}
  D -->|Yes| E[Report positional error and exit]
  D -->|No| F[Existing discovery and registration checks]
  F --> G[Register selected clients when requested]
Loading

Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/cli/strictPositionals.ts Resolved
Comment thread src/cli/strictPositionals.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@morluto

morluto commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Hey @Ha1baraA11, thanks for putting this together, the fix looks useful. What's left: it has merge conflicts with main in src/cli.ts (merging main into the branch is fine). There is 1 unresolved review thread from Greptile on an outdated line ("Tests freeze editable help text"); if it's already handled, resolving it is enough. Greptile is at 4/5 on the current head, mainly over "Tests freeze editable help text", so addressing that thread should bump it. Happy to get this in once that's sorted out.

@Ha1baraA11

Copy link
Copy Markdown
Contributor Author

Closing this PR because the underlying issue was resolved by merged PR #9057, which addresses the same MCP registration argument validation. Thanks for reviewing and testing this contribution.

@Ha1baraA11 Ha1baraA11 closed this Nov 7, 2026
@morluto morluto added area: cli CLI adapter and one-shot commands bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants