cli: programmatic ergonomics — --method initialize, --tool-args-json, --connect-timeout, env-var fixes#1651
cli: programmatic ergonomics — --method initialize, --tool-args-json, --connect-timeout, env-var fixes#1651cliffhall wants to merge 2 commits into
Conversation
…ect-timeout, env-var fixes Adds the #1573 programmatic-ergonomics surface to the CLI, re-implemented informed by PR #1510 and adapted to the v2/main OAuth-wired cli.ts: - `--method initialize` — connect-only probe emitting `{serverInfo, protocolVersion, capabilities, instructions}`. - `--tool-args-json '{"k":"v"}'` — tool args passed verbatim as JSON (no key=value coercion); mutually exclusive with `--tool-arg`, with clear errors for combined use, malformed JSON, and non-object values. - `--connect-timeout <ms>` — default 15000 for ad-hoc `--server-url`/target runs, file-level timeout otherwise; `0` disables. Backed by the exported `withConnectTimeout()` helper. - MCP_CATALOG_PATH is ignored when an ad-hoc target is given, so a shell that exports it can still run one-off ad-hoc invocations. - MCP_STORAGE_DIR is honored by core `getStateFilePath` (`<dir>/oauth.json`), below the per-file MCP_INSPECTOR_OAUTH_STATE_PATH override. Tests: new programmatic-ergonomics.test.ts (CLI, in-process runCli + direct withConnectTimeout unit tests) and getStateFilePath resolution cases in the web storage integration suite. Per-file coverage gate stays ≥90. README: documents the new flags and env-var semantics. Closes #1573 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw
|
@claude review |
|
Claude finished @cliffhall's task in 2m 0s —— View job Review — PR #1651: CLI programmatic ergonomicsI read the full diff against 🟡 1.
|
…OAuth backend Address review of PR #1651: the doc comment claimed MCP_STORAGE_DIR was honoured "across the app, so setting it once points every persist backend at the same directory", but the branch only relocates oauth.json. Narrow the comment to state it is OAuth-backend-only (client.json/mcp.json still resolve from getDefaultStorageDir → HOME) and record why the resolution lives here rather than in getDefaultStorageDir (the default-path constant is evaluated at module load, so a runtime-set MCP_STORAGE_DIR — as the CLI stored-auth / --wait-for-auth flows set it — must be read at call time). Comment-only; no behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw
|
Thanks for the thorough review. Response to each point: 🟡 1. I deliberately did not take option B (move the resolution into 🟢 2 / 🟢 3. Agreed on both — the synthesized-settings equivalence ( 🟢 4.
|
|
@claude review |
|
Claude finished @cliffhall's task in 1m 13s —— View job Review — PR #1651: CLI programmatic ergonomics (re-review)I re-read the diff against ✅ Point #1 resolved (comment now matches behavior)
It also documents the deliberate design choice not to take option B — resolving the env var at call time inside Verified Spot checks on the rest (all confirmed clean)
🟢 (Optional, non-blocking) minor edge — unchanged from before
And point #4 from the prior round ( Verdict✅ Approve-worthy. The blocking comment/behavior mismatch is fixed, the flag logic is sound, and test coverage is thorough. Nice work. |
|
Thanks — glad the fix landed cleanly. Leaving the |
Closes #1573
Programmatic-ergonomics flags and env-var fixes for the CLI, re-implemented informed by PR #1510 (
33fac3f) and adapted to the v2/main OAuth-wiredcli.ts.What changed
--method initialize— connect-only probe; prints{serverInfo, protocolVersion, capabilities, instructions}from the cachedInitializeResult.--tool-args-json '{"k":"v"}'— pass tool args verbatim as JSON (no string→number coercion). Mutually exclusive with--tool-arg; rejects combined use, malformed JSON, and non-object values.--connect-timeout <ms>— default15000for ad-hoc--server-url/target invocations (so a black-holed host fails fast), file-level timeout for catalog/config runs;0disables. Backed by the exportedwithConnectTimeout()helper.adHocgate), so a shell exporting it can still run one-off ad-hoc invocations without the catalog/ad-hoc conflict.getStateFilePath(<MCP_STORAGE_DIR>/oauth.json), sitting below the per-fileMCP_INSPECTOR_OAUTH_STATE_PATHoverride.Tests & docs
clients/cli/__tests__/programmatic-ergonomics.test.ts— in-processrunCli()coverage for each flag plus direct unit tests forwithConnectTimeoutbranches.getStateFilePathresolution cases to the web storage integration suite (covers the new MCP_STORAGE_DIR branch).clients/cli/README.mddocuments the new flags and the env-var semantics.npm run cipasses locally.Stacking
First of the Wave 3 CLI stack (#1573 → #1574 → #1575). Branches off
v2/main.🤖 Generated with Claude Code
https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw