fix(cli): stop argent mcp --help starting the server, and argent tools --help dumping the catalogue - #656
Open
filip131311 wants to merge 2 commits into
Open
fix(cli): stop argent mcp --help starting the server, and argent tools --help dumping the catalogue#656filip131311 wants to merge 2 commits into
argent mcp --help starting the server, and argent tools --help dumping the catalogue#656filip131311 wants to merge 2 commits into
Conversation
`argent mcp --help` did not print help — it started the MCP stdio server, which then blocked reading JSON-RPC from stdin. With stdin closed the server got an immediate EOF and shut down cleanly, which is why it looked like a command that printed nothing and succeeded; from a terminal it simply hung. `startMcpServer` takes no argv at all, so there was nowhere downstream for a help flag to be handled. That is the same shape as the installer commands, which already have a guard for exactly this: argv forwarded to a side-effecting function that never inspects it. `mcp` joins that set rather than growing a second help path. The guard cannot fire on a real launch — it tests `rest`, which is empty for every generated editor config, and `[].some(...)` evaluates no predicate. A test now pins that in both directions, because a guard that fired here would print usage onto the JSON-RPC channel and break every editor at handshake. The top-level table's `mcp` row now comes from the same metadata as its own help, so the two cannot drift. Fixes #638
…catalogue
The help branch was unreachable. Positional arguments were taken with
`argv.filter((a) => !a.startsWith("--"))`, which dropped `--help` before the
subcommand was read, so the command fell through to listing every tool — and
contacted the tool-server, starting one if none was running, to do it. Only the
single-dash `-h` ever reached the branch.
Help is now recognised in the subcommand position, before anything touches the
tool-server. Scoped there deliberately: `argent tools describe <name> --help`
asks for that tool's flags, and still gets them.
The usage text also documents `--help` itself, and says that listing tools starts
a server, since that is the surprise this command holds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #638.
The report understated it
The issue says
argent mcp --help"does not hang and does not start the server — it simply printsnothing". Reproducing it showed the opposite:
--helpstarts the MCP stdio server, which blocks reading JSON-RPC from stdin. The "printsnothing, exit 0" is just the server getting an immediate EOF from a closed stdin. So this is the same
"
--helpruns the real command" bug that was fixed for the installers —mcpwas missed.startMcpServertakes no argv at all (mcp-server.ts:96— its only parameter is{ paths }), so ahelp flag was structurally unreachable; there was nowhere downstream that could have handled it.
Fix
mcpjoins the existing guarded set rather than growing a second help path. That set's definingproperty is "the handler never inspects its argv", and
mcpqualifies more strongly than theinstallers do — it isn't merely ignoring
rest, it is never handed it.It cannot fire on a real launch. The guard tests
rest, which is[]for every generated editorconfig (all four shapes end at
mcp, andisArgentManagedEntryrequires exactly that), and[].some(...)evaluates no predicate. This is pinned in both directions, because a guard that didfire here would print usage onto the JSON-RPC channel and break every editor at handshake — the
highest-cost regression in this file, and it was untested.
The top-level table's
mcprow now reads the same metadata as its own help, so the two cannot drift.No rename. An earlier draft renamed the module and six identifiers (
installer-help→command-help, etc.) on the grounds that its comments had become false. They hadn't quite: fixingmcpandtoolsmakes "every other subcommand parses--helpitself" true again — I checked allten siblings. Since #530 and #568 both edit
cli.ts, a rename would have forced them through churnfor no behavioural gain. Prose-only.
Second commit:
argent tools --helpThe issue mentions it in passing; it's a different mechanism and a genuinely dead branch.
argv.filter((a) => !a.startsWith("--"))dropped--helpbefore the subcommand was read, so it fellthrough to listing all 77 tools — contacting the tool-server, starting one if none was running,
to do it. Only
-hever reached the existing help branch.Scoped to the subcommand position on purpose: a global check would have broken
argent tools describe <name> --help, which today prints that tool's flags. It still does — thereis a test.
Separate commit so it can be reverted alone.
Verification
Live, against the built CLI:
mcp --help, stdin openmcp --help, stdin closedmcp(real launch)initializehandshake, server replies with its capabilitiesmcp --metro-port 8082tools --helptools describe gesture-tap --helpargent --helpmcprowargent 80 passed, argent-cli 284 passed.
Note on the help text
Every claim in it is sourced (stdio/JSON-RPC transport, stdout ownership, the
~/.argent/mcp-calls.logdefault and
ARGENT_MCP_LOGoverride, auto-spawn vsARGENT_TOOLS_URL/argent link). It deliberatelydoes not suggest running
argent mcpby hand to check an install — that is the reported hang — andinstead says it will look like it has hung and why.
🤖 Generated with Claude Code