Repository navigation
fix(cli): derive the tslink mcp --help tool list from the registry - #59
Merged
Merged
Conversation
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.
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.
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.
What
tslink mcp --helpnamed a hand-written list of 21 tools; the server registers 48. The list is now built frommcpToolDefinitionswhen help is printed, so it cannot go stale again. The help also states the count and that a reduced--scopelists fewer.The registry is filled by
initfunctions in several files, some of which run aftermcp.go's, so the command'sLongtext cannot read it at construction time. A help func on themcpcommand renders the list at print time (tslink mcp --help,-handhelp mcpall go through it).Nested
--helpI 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> -handhelp <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, atslink <path>usage line, every local flag, every subcommand.TestCompiledMCPHelpListsTheRegisteredTools: the tool list and count inmcp --helpequal the registry.TestMCPClientsDocStatesTheOwnerToolCount:docs/mcp-clients.mdsays the owner tool count the registry has.Reverting the
mcp.gochange 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 hiddenmanifestcommand is skipped by design). The expected MCP tool list is built straight frommcpToolDefinitions, 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.jsonis unchanged (it records Short and flags, not Long).