[GH-ISSUE #7375] [Bug] mcp add writes client configuration despite an unexpected positional argument #4383

Open
opened 2026-10-31 00:49:23 +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/7375

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

node scripts/rea.mjs mcp add extra --agent amp --command 'node --version' --json ignores extra, exits 0, reports successful Amp registration, and creates $HOME/.config/amp/settings.json. Public help declares rea mcp add [options], with no positional arguments. The same command without extra succeeds as a valid control.

Reproduction

Use Node.js 24.22.1 and a checkout at the source revision below. Dependencies were already installed; npm run build:cached was executed successfully. Fresh-checkout preparation is npm ci && npm run build:cached; the dependency installation was not repeated during verification.

Run from the checkout root with disposable configuration directories:

WORK=$(mktemp -d)
export HOME="$WORK/home" XDG_CONFIG_HOME="$WORK/config" XDG_DATA_HOME="$WORK/data"
export XDG_CACHE_HOME="$WORK/cache" XDG_STATE_HOME="$WORK/state" TMPDIR="$WORK/tmp"
mkdir -p "$HOME" "$TMPDIR"
node scripts/rea.mjs mcp add extra --agent amp --command 'node --version' --json
echo "exit=$?"
cat "$HOME/.config/amp/settings.json"

The malformed invocation reproduced twice in separate isolated homes. Amp selection uses the direct configuration writer and avoids the external package runner. node --version is only a harmless stored command string; registration does not run it.

Expected behavior

Reject extra with a nonzero exit status before registration or configuration writes. docs/cli.md:942-944 explicitly promises surplus positional rejection before execution, including commands that accept no positionals. Observed mcp add --help declares only options.

Impact and scope

P2: invalid CLI input produces false success and a persistent client configuration write. Supplying only the declared options is a directly verified workaround. The observed write was limited to isolated Amp configuration; automatic registration across other agents and other platforms was not independently tested. No analysis target or security boundary was involved.

REA version

Exact node scripts/rea.mjs --version output: 6.8.0. Source commit: 0e17aab45196eb298e761f9ed0e846404e01eefa.

Runtime and platform

Node.js v24.22.1; macOS 27.0.1; Darwin arm64.

Target and artifact context

No analysis target; a disposable Amp settings file is the output artifact. No real client configuration, provider, device, or live external service was used.

Interface

CLI

Earliest failure stage

Request parsing or validation

Relevant output or evidence

Both malformed runs exited 0 with empty stderr and reported:

✓ Registered rea as MCP server
  Agents: Amp

The created settings contained:

{"amp.mcpServers":{"rea":{"command":"node","args":["--version"]}}}

A registered-command control, node scripts/rea.mjs capabilities extra --json, exited 1 and identified Unexpected positional arguments: "extra". Separately, completions bash extra exited 0 twice and generated a 727-byte script, while valid completions bash generated a 926-byte script with the portable Bash registration fallback. These completion observations corroborate the built-in validation gap; the generated scripts were not sourced.

Typed outcome or recovery expected

A validation failure identifying the unexpected token before any registration side effect. Preserve successful valid registration and completion invocations; no particular error code is required by this report.

Analysis or suspected cause

Source-derived: src/cli.ts:169-181 installs the surplus guard through src/cli/strictPositionals.ts:56, which visits registered commands. src/cli/completions.ts:47 records that Incur built-ins are absent from that command map. The pinned Incur 0.6.1 built-in mcp add handler parses selected flags and ignores other tokens before registration. For completions, src/cli/completions.ts:128-133 hands the extra-token shape back to Incur rather than rejecting it.

Additional context

Closed #6448 added surplus validation for registered commands; the built-in case above still reproduces on the stated current-main revision. Closed #5528 concerns completion candidate scope. Open #5811 concerns Windows registration failing before configuration writes, a different behavior. No exact open duplicate was found. The first affected release is unknown.

Originally created by @coygeek on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/7375 ## 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 `node scripts/rea.mjs mcp add extra --agent amp --command 'node --version' --json` ignores `extra`, exits 0, reports successful Amp registration, and creates `$HOME/.config/amp/settings.json`. Public help declares `rea mcp add [options]`, with no positional arguments. The same command without `extra` succeeds as a valid control. ## Reproduction Use Node.js 24.22.1 and a checkout at the source revision below. Dependencies were already installed; `npm run build:cached` was executed successfully. Fresh-checkout preparation is `npm ci && npm run build:cached`; the dependency installation was not repeated during verification. Run from the checkout root with disposable configuration directories: ```sh WORK=$(mktemp -d) export HOME="$WORK/home" XDG_CONFIG_HOME="$WORK/config" XDG_DATA_HOME="$WORK/data" export XDG_CACHE_HOME="$WORK/cache" XDG_STATE_HOME="$WORK/state" TMPDIR="$WORK/tmp" mkdir -p "$HOME" "$TMPDIR" node scripts/rea.mjs mcp add extra --agent amp --command 'node --version' --json echo "exit=$?" cat "$HOME/.config/amp/settings.json" ``` The malformed invocation reproduced twice in separate isolated homes. Amp selection uses the direct configuration writer and avoids the external package runner. `node --version` is only a harmless stored command string; registration does not run it. ## Expected behavior Reject `extra` with a nonzero exit status before registration or configuration writes. `docs/cli.md:942-944` explicitly promises surplus positional rejection before execution, including commands that accept no positionals. Observed `mcp add --help` declares only options. ## Impact and scope P2: invalid CLI input produces false success and a persistent client configuration write. Supplying only the declared options is a directly verified workaround. The observed write was limited to isolated Amp configuration; automatic registration across other agents and other platforms was not independently tested. No analysis target or security boundary was involved. ## REA version Exact `node scripts/rea.mjs --version` output: `6.8.0`. Source commit: `0e17aab45196eb298e761f9ed0e846404e01eefa`. ## Runtime and platform Node.js v24.22.1; macOS 27.0.1; Darwin arm64. ## Target and artifact context No analysis target; a disposable Amp settings file is the output artifact. No real client configuration, provider, device, or live external service was used. ## Interface CLI ## Earliest failure stage Request parsing or validation ## Relevant output or evidence Both malformed runs exited 0 with empty stderr and reported: ```text ✓ Registered rea as MCP server Agents: Amp ``` The created settings contained: ```json {"amp.mcpServers":{"rea":{"command":"node","args":["--version"]}}} ``` A registered-command control, `node scripts/rea.mjs capabilities extra --json`, exited 1 and identified `Unexpected positional arguments: "extra"`. Separately, `completions bash extra` exited 0 twice and generated a 727-byte script, while valid `completions bash` generated a 926-byte script with the portable Bash registration fallback. These completion observations corroborate the built-in validation gap; the generated scripts were not sourced. ## Typed outcome or recovery expected A validation failure identifying the unexpected token before any registration side effect. Preserve successful valid registration and completion invocations; no particular error code is required by this report. ## Analysis or suspected cause Source-derived: `src/cli.ts:169-181` installs the surplus guard through `src/cli/strictPositionals.ts:56`, which visits registered commands. `src/cli/completions.ts:47` records that Incur built-ins are absent from that command map. The pinned Incur 0.6.1 built-in `mcp add` handler parses selected flags and ignores other tokens before registration. For completions, `src/cli/completions.ts:128-133` hands the extra-token shape back to Incur rather than rejecting it. ## Additional context Closed [#6448](https://github.com/morluto/rea/issues/6448) added surplus validation for registered commands; the built-in case above still reproduces on the stated current-main revision. Closed [#5528](https://github.com/morluto/rea/issues/5528) concerns completion candidate scope. Open [#5811](https://github.com/morluto/rea/issues/5811) concerns Windows registration failing before configuration writes, a different behavior. No exact open duplicate was found. The first affected release is unknown.
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#4383
No description provided.