[GH-ISSUE #7585] [Bug] MCP doctor completion suggests seven options its command rejects #4521

Closed
opened 2026-10-31 00:50:28 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @coygeek on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/7585

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

CLI

Observed behavior

The Bash hook generated by node scripts/rea.mjs completions bash returns eleven long-option candidates for rea mcp doctor --. Seven candidates cannot be used with that command: executing each returns exit 1 with VALIDATION_ERROR and an unknown-option message.

For example, completion suggests --token-limit, but node scripts/rea.mjs mcp doctor --token-limit 5 prints:

code: VALIDATION_ERROR
message: "Unknown mcp doctor option: --token-limit"

The command's own help lists four long options and explicitly limits acceptance to that list. Those four options succeeded in the independent verification.

Reproduction

Use the baseline below with locked dependencies installed and the runtime already built, running Node.js v24.22.1. From the checkout root, run this Bash probe. No target fixture is needed. The independent verification used disposable HOME, XDG and temporary directories and removed inherited REA/provider settings.

  1. Load the generated hook and inspect the candidate list:

    rea() { node scripts/rea.mjs "$@"; }
    eval "$(rea completions bash)"
    COMP_WORDS=(rea mcp doctor --)
    COMP_CWORD=3
    _incur_complete_rea 2>/dev/null
    printf '%s\n' "${COMPREPLY[@]}"
    

    The callback's stderr redirection suppresses the non-interactive compopt message; command-generation and command-execution errors were checked separately.

  2. Execute an offered option and inspect the supported contract:

    node scripts/rea.mjs mcp doctor --token-limit 5
    printf 'exit=%s\n' "$?"
    node scripts/rea.mjs mcp doctor --help
    
  3. Compare a supported diagnostic invocation:

    node scripts/rea.mjs mcp doctor --json
    printf 'exit=%s\n' "$?"
    

The hook returned the eleven candidates shown below in one independent run. The unsupported candidate exited 1; help exited 0; the JSON diagnostic exited 0 and reported healthy: true. Each additional unsupported flag listed in Evidence was also executed once and rejected. Supported --format json and --full-output controls each exited 0.

Expected behavior

Options suggested for the active mcp doctor command should reflect that command's supported option set. The extra framework globals should not be presented as available doctor options.

The current CLI guide describes completion as a discovery aid and tells callers to confirm available options with command help; it does not guarantee exact candidate/parser parity. The executed doctor help is explicit: it lists --format, --json, --full-output, and --help, -h, then says, “This entry accepts only the options above.” The requested correction is to option discovery; this report does not establish a requirement to add new output controls to doctor. Exact source references are in Evidence and Analysis.

Impact and scope

P2: users following option completion can select a flag that prevents the diagnostic from running. This is bounded and has a demonstrated workaround: consult command help and use the supported flags. JSON, format selection and full-output diagnostics succeeded in this verification. No analysis target or data damage was involved.

Only the generated Bash hook was exercised. Other shells share the candidate computation in source, but their interactive behavior was not tested.

REA version

Exact node scripts/rea.mjs --version stdout: 6.8.0 followed by a newline.
Source baseline: 65f1c447344a423fa2785847dbcea1e9a9e2454a.

Runtime and platform

Node.js v24.22.1; macOS 27.0.1; darwin arm64; macOS system Bash. No Hopper or Ghidra operation was required.

Target and artifact context

Not applicable. Static option completion and the target-free local production MCP diagnostic.

Interface

CLI

Earliest failure stage

Transport or result projection

Relevant output or evidence

The executed generated-hook callback returned:

--format
--filter-output
--token-limit
--token-offset
--full-output
--llms
--llms-full
--help
--schema
--json
--token-count

The following command suffixes were each executed after node scripts/rea.mjs mcp doctor:

--filter-output healthy
--token-limit 5
--token-offset 0
--llms
--llms-full
--schema
--token-count

Each exited 1, wrote code: VALIDATION_ERROR and message: "Unknown mcp doctor option: <flag>" to stdout, and had empty stderr. Help exited 0 with empty stderr and the four-option list above. Both JSON controls parsed successfully; --full-output returned ok: true with a healthy diagnostic inside data.

Source locators at the stated baseline:

  • docs/cli.md:149-173: generated-hook setup, inclusion of globals, and discovery-aid/help qualification.
  • docs/cli.md:946-952: doctor-specific JSON and full-output documentation.
  • src/mcpDoctor.ts:37-78: restricted option schema and help contract; 491-543: argument acceptance and unknown-option rejection.
  • scripts/rea.mjs:26-35,69-80: separate production-doctor dispatch outside ordinary framework command execution.
  • src/cli/completions.ts:20-42,63-66,108-116: generic global metadata, doctor completion entry, and globals passed into candidate generation.

Typed outcome or recovery expected

Omit unsupported doctor-option candidates while retaining the supported output flags and help. The parser's clear rejection of unsupported input can remain unchanged.

Analysis or suspected cause

Source-derived: REA supplies generic non-root globals to completion for the doctor leaf even though production doctor has a narrower parser. The locked Incur implementation (node_modules/incur/src/Completions.ts:84-129) appends global candidates independently of command-local options. Consequently, merely adding a doctor option schema without changing the applicable globals would still suggest unsupported flags.

Additional context

Open and closed issues, issue comments, and open/closed/merged PRs were searched. Closed #1127 concerned doctor help being rejected; that request now succeeds. Closed #5526 concerned missing usable globals on instructions, #5527 Bash registration, and #5528 unrelated command-name candidates after mcp. This report concerns excess option candidates after mcp doctor, with a different restoration check. Closed feature #5481 requested supported flags and alignment with command definitions; it does not report this specific mismatch. Open #7372 concerns non-JSON debug output in restricted tool-family scopes, which is separate from static completion.

NOT_ENOUGH_INFO: no last-known-good version was established. The focused test:local invocation for existing completion/help boundary files was refused before execution because those files require the built-project runner; no test-suite pass is claimed. The public-CLI observations above were executed independently. No repair was made.

Originally created by @coygeek on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/7585 ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area CLI ### Observed behavior The Bash hook generated by `node scripts/rea.mjs completions bash` returns eleven long-option candidates for `rea mcp doctor --`. Seven candidates cannot be used with that command: executing each returns exit 1 with `VALIDATION_ERROR` and an unknown-option message. For example, completion suggests `--token-limit`, but `node scripts/rea.mjs mcp doctor --token-limit 5` prints: ```text code: VALIDATION_ERROR message: "Unknown mcp doctor option: --token-limit" ``` The command's own help lists four long options and explicitly limits acceptance to that list. Those four options succeeded in the independent verification. ### Reproduction Use the baseline below with locked dependencies installed and the runtime already built, running Node.js v24.22.1. From the checkout root, run this Bash probe. No target fixture is needed. The independent verification used disposable HOME, XDG and temporary directories and removed inherited REA/provider settings. 1. Load the generated hook and inspect the candidate list: ```bash rea() { node scripts/rea.mjs "$@"; } eval "$(rea completions bash)" COMP_WORDS=(rea mcp doctor --) COMP_CWORD=3 _incur_complete_rea 2>/dev/null printf '%s\n' "${COMPREPLY[@]}" ``` The callback's stderr redirection suppresses the non-interactive `compopt` message; command-generation and command-execution errors were checked separately. 2. Execute an offered option and inspect the supported contract: ```bash node scripts/rea.mjs mcp doctor --token-limit 5 printf 'exit=%s\n' "$?" node scripts/rea.mjs mcp doctor --help ``` 3. Compare a supported diagnostic invocation: ```bash node scripts/rea.mjs mcp doctor --json printf 'exit=%s\n' "$?" ``` The hook returned the eleven candidates shown below in one independent run. The unsupported candidate exited 1; help exited 0; the JSON diagnostic exited 0 and reported `healthy: true`. Each additional unsupported flag listed in Evidence was also executed once and rejected. Supported `--format json` and `--full-output` controls each exited 0. ### Expected behavior Options suggested for the active `mcp doctor` command should reflect that command's supported option set. The extra framework globals should not be presented as available doctor options. The current CLI guide describes completion as a discovery aid and tells callers to confirm available options with command help; it does not guarantee exact candidate/parser parity. The executed doctor help is explicit: it lists `--format`, `--json`, `--full-output`, and `--help, -h`, then says, “This entry accepts only the options above.” The requested correction is to option discovery; this report does not establish a requirement to add new output controls to doctor. Exact source references are in Evidence and Analysis. ### Impact and scope P2: users following option completion can select a flag that prevents the diagnostic from running. This is bounded and has a demonstrated workaround: consult command help and use the supported flags. JSON, format selection and full-output diagnostics succeeded in this verification. No analysis target or data damage was involved. Only the generated Bash hook was exercised. Other shells share the candidate computation in source, but their interactive behavior was not tested. ### REA version Exact `node scripts/rea.mjs --version` stdout: `6.8.0` followed by a newline. Source baseline: `65f1c447344a423fa2785847dbcea1e9a9e2454a`. ### Runtime and platform Node.js v24.22.1; macOS 27.0.1; darwin arm64; macOS system Bash. No Hopper or Ghidra operation was required. ### Target and artifact context Not applicable. Static option completion and the target-free local production MCP diagnostic. ### Interface CLI ### Earliest failure stage Transport or result projection ### Relevant output or evidence The executed generated-hook callback returned: ```text --format --filter-output --token-limit --token-offset --full-output --llms --llms-full --help --schema --json --token-count ``` The following command suffixes were each executed after `node scripts/rea.mjs mcp doctor`: ```text --filter-output healthy --token-limit 5 --token-offset 0 --llms --llms-full --schema --token-count ``` Each exited 1, wrote `code: VALIDATION_ERROR` and `message: "Unknown mcp doctor option: <flag>"` to stdout, and had empty stderr. Help exited 0 with empty stderr and the four-option list above. Both JSON controls parsed successfully; `--full-output` returned `ok: true` with a healthy diagnostic inside `data`. Source locators at the stated baseline: - `docs/cli.md:149-173`: generated-hook setup, inclusion of globals, and discovery-aid/help qualification. - `docs/cli.md:946-952`: doctor-specific JSON and full-output documentation. - `src/mcpDoctor.ts:37-78`: restricted option schema and help contract; `491-543`: argument acceptance and unknown-option rejection. - `scripts/rea.mjs:26-35,69-80`: separate production-doctor dispatch outside ordinary framework command execution. - `src/cli/completions.ts:20-42,63-66,108-116`: generic global metadata, doctor completion entry, and globals passed into candidate generation. ### Typed outcome or recovery expected Omit unsupported doctor-option candidates while retaining the supported output flags and help. The parser's clear rejection of unsupported input can remain unchanged. ### Analysis or suspected cause Source-derived: REA supplies generic non-root globals to completion for the doctor leaf even though production doctor has a narrower parser. The locked Incur implementation (`node_modules/incur/src/Completions.ts:84-129`) appends global candidates independently of command-local options. Consequently, merely adding a doctor option schema without changing the applicable globals would still suggest unsupported flags. ### Additional context Open and closed issues, issue comments, and open/closed/merged PRs were searched. Closed #1127 concerned doctor help being rejected; that request now succeeds. Closed #5526 concerned missing usable globals on `instructions`, #5527 Bash registration, and #5528 unrelated command-name candidates after `mcp`. This report concerns excess option candidates after `mcp doctor`, with a different restoration check. Closed feature #5481 requested supported flags and alignment with command definitions; it does not report this specific mismatch. Open #7372 concerns non-JSON debug output in restricted tool-family scopes, which is separate from static completion. NOT_ENOUGH_INFO: no last-known-good version was established. The focused `test:local` invocation for existing completion/help boundary files was refused before execution because those files require the built-project runner; no test-suite pass is claimed. The public-CLI observations above were executed independently. No repair was made.
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#4521
No description provided.