fix(mcp): print usage help for bare loopover-mcp invocation instead of starting stdio server - #8486
Conversation
…f starting stdio server A bare `loopover-mcp` (zero arguments) fell through the CLI-dispatch gate, whose guard required `cliArgs[0]` to be truthy, and reached the unconditional StdioServerTransport bind -- silently starting the MCP stdio server and hanging on a plain terminal that never sends JSON-RPC, instead of printing usage help. Relax the entry gate so a zero-arg invocation reaches `runCli([])`, and add a `command === undefined` case to runCli's existing --help/help branch so it prints the usage banner via printHelp() and exits 0. Only an explicit --stdio invocation still starts the stdio server; --stdio behavior is unchanged. Export runCli (separate statement, mirroring runAgentCli/maintainCli) so a new in-process test drives the changed branch for Codecov coverage; a dedicated regression test also asserts the bare subprocess exits 0 with the banner. Closes JSONbored#8313
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8486 +/- ##
===========================================
+ Coverage 66.08% 82.50% +16.41%
===========================================
Files 791 98 -693
Lines 79333 24962 -54371
Branches 23961 4729 -19232
===========================================
- Hits 52430 20594 -31836
+ Misses 22909 4176 -18733
+ Partials 3994 192 -3802
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-24 15:31:28 UTC
Review summary Nits — 3 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
Running
loopover-mcpwith no arguments — the natural first thing a new user tries — silently started the stdio MCP server and hung waiting for JSON-RPC input, instead of printing usage help.Two top-level gates in
packages/loopover-mcp/bin/loopover-mcp.tscaused this:if (runAsCliEntrypoint && cliArgs[0] && cliArgs[0] !== "--stdio")) only ran whencliArgs[0]was truthy. A bare invocation leavescliArgs[0]asundefined, so the whole block was skipped — norunCli, noprocess.exit.if (runAsCliEntrypoint) await server.connect(new StdioServerTransport()), binding the stdio transport to the real stdin/stdout — the exact effective behavior ofloopover-mcp --stdio.Fix
:1645): drop thecliArgs[0] &&truthiness requirement so a zero-argument invocation reachesrunCli([])instead of falling through to the stdio bind. An explicit--stdiois still routed to the server (its behavior is unchanged).runCli(:4105): addcommand === undefinedto the existing--help/helpbranch sorunCli([])prints the usage banner viaprintHelp()and returns (exit 0), mirroring the existing help handling rather than reaching the "Unknown command" path.runCliis exported as a separate statement (same rationale as the neighboringrunAgentCli/maintainCliexports) so an in-process unit test can drive the new branch for Codecov coverage — a bare invocation is otherwise only reachable via subprocess spawn, which v8 coverage cannot instrument.Only an explicit
loopover-mcp --stdiostarts the MCP stdio server now; a bareloopover-mcpbehaves like every other documented CLI's bare invocation — it prints usage help and exits.Tests
New dedicated
test/unit/mcp-cli-bare-invocation.test.ts:runCli([]),runCli(["--help"]),runCli(["help"])— asserting all three produce byte-identical usage output — plusrunCli(["version"])to exercise the changed condition's false path. This covers the newcommand === undefinedbranch's statement and every branch (bothifoutcomes and all three||operands).--help, proving the end-to-end entry-gate fix.Closes #8313