Skip to content

fix(cli): derive the tslink mcp --help tool list from the registry - #59

Merged
monody0007 merged 2 commits into
mainfrom
fix/cli-nested-help
Oct 23, 2026
Merged

monody0007 merged 2 commits into
mainfrom
fix/cli-nested-help

Conversation

@monody0007

@monody0007 monody0007 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What

tslink mcp --help named a hand-written list of 21 tools; the server registers 48. The list is now built from mcpToolDefinitions when help is printed, so it cannot go stale again. The help also states the count and that a reduced --scope lists fewer.

The registry is filled by init functions in several files, some of which run after mcp.go's, so the command's Long text cannot read it at construction time. A help func on the mcp command renders the list at print time (tslink mcp --help, -h and help mcp all go through it).

Nested --help

I could not reproduce the nested-help fallback on current main. For all 73 manifest commands below the root (42 of them two or more levels deep, including the hidden manifest), <cmd> --help, <cmd> -h and help <cmd> print the command's own usage, exit 0, stderr empty. The symptom does reproduce when a multi-word command is passed as one argument (tslink "tags list" --help, which is what an unsplit shell variable does): that is an unknown command and prints the root help. So no routing change here; the new tests pin the behaviour.

Tests

  • TestCompiledEveryCommandHelpIsItsOwn: compiled binary, every visible command in three spellings; asserts exit 0, empty stderr, output differs from root help, a tslink <path> usage line, every local flag, every subcommand.
  • TestCompiledMCPHelpListsTheRegisteredTools: the tool list and count in mcp --help equal the registry.
  • TestMCPClientsDocStatesTheOwnerToolCount: docs/mcp-clients.md says the owner tool count the registry has.

Reverting the mcp.go change turns the mcp test red (3 of 3 spellings); making help for nested commands print the root help turns the nested subtests red. The visible-command test runs 216 subtests (72 visible commands × 3 spellings; the hidden manifest command is skipped by design). The expected MCP tool list is built straight from mcpToolDefinitions, so a name-collecting helper that drops a tool fails the test (checked by mutation: 47 vs 48).

go test -count=1 ./..., go vet ./..., gofmt, scripts/check.sh (build, vet x4 platforms, tidy, staticcheck x3, gen-manifest -check, gen-notices -check) pass locally. docs/cli-manifest.json is unchanged (it records Short and flags, not Long).

tslink mcp --help named a hand-kept list of 21 tools while the server
registers 48. Build the list from mcpToolDefinitions when help is printed
(the registry is filled by init functions in several files, so the command's
Long text cannot read it at construction time).

Add compiled-binary tests that run --help, -h and help <cmd> for every
command in the tree, nested ones included, and require each to print its own
usage, flags and subcommands rather than the root help; a test that the mcp
help list equals the registry; and one that pins the owner tool count in
docs/mcp-clients.md.
@monody0007
monody0007 requested a review from a team as a code owner October 23, 2026 21:18
The help consistency test reused mcpRegisteredToolNames for its expected
set, so a helper that dropped a name would agree with itself. Read
mcpToolDefinitions directly instead.
@monody0007
monody0007 merged commit 3b103ff into main Oct 23, 2026
18 of 32 checks passed
@monody0007
monody0007 deleted the fix/cli-nested-help branch October 23, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant