Skip to content

fix(cli): prevent mcp discovery from registering clients - #7919

Merged
morluto merged 2 commits into
mainfrom
codex/mcp-add-discovery-7580
Oct 29, 2026
Merged

morluto merged 2 commits into
mainfrom
codex/mcp-add-discovery-7580

Conversation

@morluto

@morluto morluto commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Related to #7580. rea mcp add --agent amp --schema --json previously registered the server while the caller requested discovery. It now reports SCHEMA_UNAVAILABLE without changing client settings; --version returns the version without registering. This stops the unintended writes but does not provide the requested schema.

Problem and expected behavior

Incur dispatches its MCP registration builtin before its schema and version handling. Discovery must not apply configuration changes.

Change and scope

Use REA's existing Incur builtin argument split to recognize discovery before dispatch. Return an explicit unsupported-schema error, formatted using the shared CLI output parser, and preserve help and manifest precedence. CSV/TSV are rejected as unable to represent the error document. Ordinary registration remains owned by Incur. The similar optional Incur skills installer is disabled by REA. PR #7453 addresses the separate surplus-positional issue #7375.

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI builtin argument extraction, before MCP registration dispatch.
  • Contribution scope fit and linked maintainer decision: existing CLI registration behavior; no new provider or target authority.
  • CLI and MCP/tool-catalog contract: schema requests for mcp add explicitly fail with SCHEMA_UNAVAILABLE rather than registering; use rea mcp add --help to inspect options.
  • Provider, bridge, target-format, or platform compatibility: no provider or target changes.
  • Evidence, artifact, provenance, or reconstruction contract: no change.
  • Target selection, authority, upstream behavior, and cleanup details: no target interaction; regular client registration remains unchanged.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Change process memory, registers, files, or configuration. (Ordinary MCP registration remains available; discovery does not write.)

Evidence and regression coverage

  • Tests added: a public CLI boundary test checks absent and existing Amp settings, schema JSON refusal, help/version, an invalid flag-shaped format value, valid CSV/TSV requests, and normal Amp registration.
  • Base reproduction: issue [Bug] Schema discovery for mcp add applies an Amp registration #7580 reports executed Amp schema/version requests creating settings; this change was validated using isolated temporary HOME directories.
  • User-visible output: --schema --json returns code SCHEMA_UNAVAILABLE and directs users to mcp add --help.
  • Remaining proof gaps: test executed on macOS; other OS and clients were not exercised. Registration still delegates to Incur.

Validation performed

  • npm run build:cached with Node 24.22.1 — passed.
  • npm run test:focused -- tests/boundary/cli/mcpAddDiscovery.test.ts with Node 24.22.1 — passed.
  • npm run test:focused -- tests/boundary/cli/cliOutput.test.ts with Node 24.22.1 — passed (64 tests).
  • npm run check:fast and npm run lint — blocked by duplicate imports already present on the base revision in tests/boundary/mcp/serverUnknownsMcp.test.ts (lines 2–3 and 31–32).

Compatibility, safety, and release

  • Discovery calls that formerly performed registration now return discovery output or an explicit error. No migration.
  • No real provider verification applies; the public CLI test exercises Amp's local settings integration, not an Amp session.
  • No package or release metadata changes.

Author readiness

Human owner: @morluto

  • 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.

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

chatgpt-codex-connector Bot commented Oct 28, 2026 •

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 ✅ Completed 2026-10-28T21:26:00.961665Z 242773c 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.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous format-parsing finding is fixed and no new blocking issue was found.

Summary

The PR stops mcp add discovery requests before client registration.

  • MCP add handles discovery requests before changing client settings.

No new actionable issues or security concerns were found. Review conclusions are based on source checks; no runtime tests were run. Whether another PR supersedes this one could not be checked because GitHub access required authentication.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Normalized CLI arguments] --> B{mcp add discovery?}
  B -->|Schema| C[Parse shared output controls]
  C --> D[Write schema or output-control error]
  D --> E[Exit without registration]
  B -->|Version| F[Write version without registration]
  B -->|Help, manifest, or ordinary command| G[Existing Incur dispatch]
Loading

Reviews (2) · Last reviewed commit: "fix(cli): use shared output parsing for ..." · Reviewed by Greptile

Comment thread src/cli.ts Resolved
@morluto
morluto merged commit 9e1a1e7 into main Oct 29, 2026
42 of 46 checks passed
@morluto
morluto deleted the codex/mcp-add-discovery-7580 branch October 29, 2026 00:57
@morluto morluto added area: cli CLI adapter and one-shot commands bug Something isn't working labels Nov 22, 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.

1 participant