Repository navigation
Conversation
[Medium impact] The reviewed changes appear safe to merge; no new actionable defect was established. SummaryThis PR sends JSON registration requests directly to
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CLI arguments] --> B[Normalize output and registration options]
B --> C{Selected mode}
C -->|Discovery or other mode| D[Existing dispatcher]
C -->|JSON registration| E{Amp selected or default}
E -->|Yes| F[Check settings and create backup]
F --> G[SyncMcp.register]
E -->|No| G
G -->|Failure| H[Write one redacted error document]
G -->|Success| I[Redact and filter result]
I --> J{Amp verification required}
J -->|Yes| K[Verify settings and restore prior environment]
K -->|Passed| L[Write success document]
K -->|Failed| M[Write validation error]
J -->|No| L
Reviews (6) · Last reviewed commit: "fix(cli): reconcile MCP JSON registratio..." · Reviewed by Greptile |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
🔵 Needs a closer look
The change reimplements a complex CLI/MCP registration contract across multiple consumers and was only partly validated via cloud without a full local recheck, leaving verification incomplete.
No open issues 🎉
What changed in this PR
This PR fixes #7610, where rea mcp add --agent amp --json emitted human progress text, a terminal clear-line escape, and success prose ahead of the registration object, making a successful registration's stdout unparseable as JSON. Rather than scrape a JSON suffix out of Incur's mixed human output or patch the pinned dependency, REA's existing registration wrapper now calls Incur's public SyncMcp.register producer directly for the JSON format and renders a single structured result/error document. The change also hardens the shared builtin argument split so Incur's boolean timing-global forms cannot hide registration dispatch, and replaces the old late, token-wide equals-expansion with a scoped normalizeMcpAddArguments pass that only expands actual registration options before mode selection.
Changes:
- Add
normalizeMcpAddArguments, and track per-token source positions (commandIndices) plus timing-global (--timings/--no-timings/--timings=…until--) extraction insplitIncurBuiltinArguments, replacing the superseded inline late expansion. - In
src/cli.ts, add aserveRegistrationpath that, for JSON, invokesSyncMcp.registerand defers a single success document viaflushRegistration(after Amp backup/verification), while failures emit oneMCP_ADD_FAILEDdocument with nonzero status; non-JSON/other formats keep their prior presentation. - Add
tests/boundary/cli/mcpAddJsonOutput.test.tscovering single-document JSON parsing, Amp settings/backup preservation, runner forwarding and failure status, discovery/mode precedence, timing-global forms, equals-shaped literal values, and sensitive-value redaction.
| File | Description |
|---|---|
src/cliBuiltinArguments.ts |
Adds commandIndices to the split, aligns timing-global extraction with Incur's parser, and introduces the scoped normalizeMcpAddArguments expansion. |
src/cli.ts |
Routes JSON mcp add through SyncMcp.register with deferred single-document flushing and single-error failure handling; preserves Amp guard/backup and non-JSON output. |
tests/boundary/cli/mcpAddJsonOutput.test.ts |
New boundary tests validating the one-document JSON contract, side effects, failure status, and argument-handling edge cases. |
Review effort: Balanced
Preserve scoped argument normalization and JSON registration output alongside default Amp guards and global timing parsing. Validation: exact tree 5b31610 matches the reviewed Linux result (25 focused tests, npm run check and test discovery). Local patch checksum, tree, diff and index checks passed.
Check registration success and failure through parsed documents, typed codes, settings bytes, and backup paths.
Incur filters successful registration data before formatting. The direct JSON document uses that same filter, while failure documents keep their typed codes.
|
Hey @maxazure, thanks for putting this together, the fix looks useful. What's left: it has merge conflicts with main in |
Summary
Fixes #7610.
rea mcp add --agent amp --jsonnow emits one parseable JSON result rather than mixed progress and terminal output. JSON registration calls Incur's public registration producer, preserves success filtering, and waits for Amp configuration verification before reporting success. For example, the result is{"name":"rea","command":"fixture {server} --mcp","agents":["Amp"]}.Merge current main (
71f680d7c) into the existing PR branch, retaining its commits. Resolve the CLI conflict while preserving upstream missing-value validation and Markdown argument-error encoding. Normalize actual equals-bound registration options before dispatch, preserve literal command/sensitive values and selected modes, and follow Incur's registration behavior after--. Explicitly declared sensitive text is redacted from success values and failure messages; registration still receives the original input.Current PR head:
17f9bdb8fcda4ee92e1a3ca7c6df362cdb94dc11.Validation
Local macOS arm64, Node 24.22.1, npm 11.16.0:
npm run checkpassed: typecheck, lint/module boundaries, formatting, Knip, metadata, architecture guards, production reachability and typed lint. Typed lint reported 0 errors and 4,186 advisory warnings; production reachability reported 33 files with advisory candidates.git diff --checkpassed; all seven candidate file hashes match the reviewed handoff.Tests use isolated HOME/XDG directories and recording runners. No real external-client registration or full platform test matrix was run locally. Remote static checks, source tests and package build passed for this head. Eight test shards and the Windows native build remain pending; the full CI gate is not yet complete. No tool catalog, provider or package contract change.
Author readiness
Human owner: @maxazure
Before merge
The final item remains unchecked while remote checks are pending.