Skip to content

fix(cli): preserve mcp doctor output choices on argument errors - #2693

Merged
morluto merged 2 commits into
morluto:mainfrom
jasonchen505:contrib/mcp-doctor-full-output
Nov 18, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
jasonchen505:contrib/mcp-doctor-full-output

Conversation

@jasonchen505

@jasonchen505 jasonchen505 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The normal MCP doctor full-output path is already on main. This PR now only fixes output selection when argument validation fails, as requested in the maintainer review.

For example, rea mcp doctor --bogus --full-output --json should return a JSON error envelope and exit 1 without starting MCP. Previously, parsing stopped at the first error and dropped the later output options.

Change and scope

The parser keeps the first error while continuing to collect valid output and help options. Tokens consumed by --format remain values, even when they look like flags. The last valid format wins.

The diff is limited to the parser/error path and 35 regression cases. Tests cover option ordering and assert that neither MCP connect nor transport start is called. Normal diagnostic execution is unchanged.

Scope: an argument-parsing fix within the existing CLI. No new provider, target interaction, package change, or migration is introduced; a separate scope decision is not applicable. MCP/tool-catalog, evidence, authority, and cleanup contracts are unchanged.

Validation

On the unmodified base, 25 of the initial 33 regression cases failed; all passed after the fix. Two additional TOON/Markdown cases also pass.

Executed after the final rebase with Node 24.18.0 / npm 11.16.0:

  • npm run test:focused -- tests/process-global/mcpDoctorArguments.test.ts tests/boundary/mcp/mcpDoctor.test.ts tests/boundary/cli/mcpDoctorHelpCli.test.ts — 51 passed across 3 files.
  • npm run check:fast — passed.
  • npm run check — passed (typecheck, lint, formatting, knip, metadata, architecture guards).
  • npm run verify:test-discovery — all 1,328 test files discovered exactly once.
  • git diff --check — passed.
  • Built CLI smoke checks — unknown options before selectors, missing format, and consumed full-output tokens produced the expected JSON and exit 1, with empty stderr.
  • GitHub CI — awaiting maintainer approval.

The full suite and real Hopper/Ghidra/browser lanes were not run. Existing lint/build warnings remain.

Maintainer follow-up

Resolved the conflict with current main (8a10fa9c00). One argument scan now retains the first error, consumes format values in their existing positions, and applies the last valid format and full-output option. Help and typed JSONL framing are preserved. Argument errors return before MCP startup.

The compiled CLI returned TOON for --bogus --json on main. The revised head passed all 43 focused tests, including compiled CLI and production stdio MCP coverage, plus npm run check:fast and changed-file formatting.

Author readiness

Human owner: @jasonchen505

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

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T16:05:29.567565Z 581be8e New commits
ℹ️ 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 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The changes appear safe to merge.

Summary

This PR preserves MCP doctor output choices when arguments are invalid, without changing normal diagnostic runs.

  • MCP doctor keeps later output choices when an earlier argument is invalid.

The parser fix remains distinct from the full-output support already on the base branch. No actionable correctness or security issues were found. Tests were not run during this review.

Reviews (8) · Last reviewed commit: "Merge main and keep MCP doctor output va..." · Reviewed by Greptile

Comment thread tests/boundary/mcp/mcpDoctor.test.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38056e9c35

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/mcpDoctor.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 744f4c2393

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/mcpDoctor.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1, thread 2

Source changes are on 075b43a. The argument owner now walks option positions once, retains the first validation error, and continues collecting format/full-output/help choices. A token consumed as --format's value remains a value. Validation projection therefore honors --full-output before or after an invalid option; the superseded help-only pre-scan was removed. Added ordering regressions without launching MCP for invalid invocations.

Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request.

@morluto morluto added bug Something isn't working area: cli CLI adapter and one-shot commands area: mcp MCP server, transport, and tool registration area: setup Setup, packaging, upgrade, install, Doctor, and client registration P2: medium Medium priority issue labels Oct 13, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Use one named input-schema projection for clients and catalog identity, preserve dialect declarations, and bound compact schema depth. Keep canonical SDK output validation when output advertisements are disabled. Release request-owned state on cancellation and carry upstream limitations through composed workflows. Preserve doctor full-output envelopes and validate navigation facts at their owner.

Reviewed fixes: #2088, #2108, #2513, #2684, #2693, #2695, #2836, #2864, #2868, #2877, #2933, #2998, #3002, #3015.

Validation: focused schema, SDK output-validation, context, and workflow tests passed; no schema dialect or canonical output validation was relaxed.
@CassieFox23

Copy link
Copy Markdown
Contributor

Heads up: the core of this is on main now. 80de314 added the same --full-output envelope to src/mcpDoctor.ts, and #2673 is closed.

One part is not on main yet. On this branch, a bad option still honors --full-output in any order. Main still returns a bare {code, message} for bad options.

This branch now conflicts with main. A smaller pull request with just that part may be easier to merge. I only read the code here. I did not build or run it, because every test it touches runs the MCP doctor.

🤖 Generated with Claude Code (Opus 5.5) 🦊

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Compared this PR with main fc712b375 during the fixed/superseded backlog audit.

The normal MCP doctor full-output envelope is already delivered in 80de314. The distinct remaining behavior here is collecting output selectors after a validation error, such as --bogus --full-output --json; main's parser returns at the first error and drops that choice.

Please narrow/rebase around the single argument-owner pass already described in the branch review: retain the first error, continue collecting valid format/full-output/help choices, and treat a token consumed as a --format value as a value. Keep ordering regressions and prove invalid invocations never start MCP.

PR head reviewed: d4b0718e3. This is a source comparison; no new PR-branch tests or provider runs were performed for this comment.

@jasonchen505 jasonchen505 changed the title fix(cli): honor the advertised --full-output flag in mcp doctor fix(cli): preserve mcp doctor output choices on argument errors Oct 15, 2026
@jasonchen505
jasonchen505 marked this pull request as draft October 15, 2026 08:53
@jasonchen505
jasonchen505 force-pushed the contrib/mcp-doctor-full-output branch from d4b0718 to 9816af2 Compare October 15, 2026 08:56
@jasonchen505
jasonchen505 marked this pull request as ready for review October 15, 2026 19:02
@morluto
morluto merged commit 55fd0ff into morluto:main Nov 18, 2026
42 checks passed
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 area: mcp MCP server, transport, and tool registration area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants