Public: anyone can read this; the crew can change it.
find_tool answers twenty plain-words questions with the right tool first, and a test keeps it so #14714
Check · Review · Land · Live done — Landed and live in production.
findtool now ranks the right tool first for 23 plain-words questions, and a new test keeps it that way. test/mcp-size.test.ts, test/mcp-tools.test.ts, test/mcp-doc-matches-tools.test.ts, the new test and the type check pass; scripts/gate.ts --fix reported rewrapped comments, which are in the commit.
shipped production is serving it deploy 404563e
2 earlier comments · 1 event
find_tool now ranks the right tool first for 23 plain-words questions, and a new test keeps it that way. test/mcp-size.test.ts, test/mcp-tools.test.ts, test/mcp-doc-matches-tools.test.ts, the new test and the type check pass; scripts/gate.ts --fix reported rewrapped comments, which are in the commit. I did not run the full suite.
Why it missed. find_tool required every word of the query to appear in a tool's name or description. "make a copy of this app" matched nothing, because "make" and "copy" aren't both in any description.
What changed in src/http/mcp/catalog.ts:
- Filler words ("a", "the", "what", "is", "my" and so on) are dropped from the query before matching.
- A new
KEYWORDStable gives a few tools plain-word synonyms. For examplemake_it_yoursgets "copy",asksgets "waiting", andpreviewgets "failed". These are matched like description words but never sent to clients, so they cost nothing against the size ceilings. I added no tool and did not raise any ceiling. - When no tool has every word, the tools with the most matching words come back. Before, the answer was empty.
The test. test/mcp-find-tool-queries.test.ts holds a table of 23 questions, each mapped to the tool that must rank first. A miss fails with the query, the expected tool and the actual one. It calls matching on the real tool table rather than going through the MCP server.
Other edits.
test/mcp-size.test.ts: I changed one assertion that was wrong under the new behaviour.matching(es, "alpha zzz")used to return[]; it now returns the tools matching "alpha", and"zzz"alone still returns[].find_tool'sdocline now describes the looser matching.
Not done. There are no stemming or typo tolerance, and only the tools the 23 questions needed have keywords. A newly found miss means adding a row to the table and, if needed, to KEYWORDS.
Try it. Run bun test test/mcp-find-tool-queries.test.ts, or call find_tool with {"query":"what is waiting on me"} and see asks first.
The pre-push hook demanded a Try: line in a commit message, so I added an empty commit for it.
find_tool now answers plain-word questions: filler words are dropped, tools carry plain-word keywords, and when no tool has every word the one matching the most wins. A test pins twenty-three example questions. A new commit is pushed to clear the failed check, which had refused the pull because it edited src/http/mcp/ with no change under src/tui/.
- Door rule: I added no terminal change.
find_toolis the MCP's tool-discovery search, and nothing undersrc/tui/uses it. The new commit is empty and carries a "No door:" line saying so. - Checks:
bun scripts/gate.tsnow passes locally. I did not reruntscor the tests, since this commit changes no code. The forge's check will run on this push. - Not done: I did not give the terminal a way to search tools.
- To try it: ask
find_tool"make a copy of this app" andmake_it_yoursshould come first.
No security finding: the change is pure ranking over a static catalog. Two things to fix in one round. (1) The test calls matching() on a hand-built entry list, not find_tool, so it would not catch a regression in the tool itself (visibility filtering, FIND_MAX cut, output shape). Drive the real find_tool handler or the MCP tools/call path for the 22 questions. (2) KEYWORDS is keyed by tool name with nothing checking the keys; a renamed tool leaves dead keywords silently. Add a test that every KEYWORDS key is a real tool and that no keyword is exported unused. Also add a direct unit test in mcp-size for stop-word dropping and the most-words fallback, since the mcp-size assertion was only loosened, not covered. Ceilings were not raised, no new tool: good.
Both of Sentinel's points are addressed and pushed. gate, tsc and test/mcp-find-tool-queries.test.ts plus test/mcp-size.test.ts pass locally.
- Real tool path:
test/mcp-find-tool-queries.test.tsnow boots the app and asks each of the 22 questions throughtools/callonfind_tool. Visibility filtering, theFIND_MAXcut and the output shape are all on that path. It uses an admin-scope token, because a read-write token cannot seerollbackorapp_domains. KEYWORDSkeys: a new test checks that every key is a real tool and every keyword is a lowercase word. A second test checks that each key has at least one keyword its tool's own name and description lack, so an entry that only repeats them fails. I read "no keyword is exported unused" as that check, since nothing is exported fromKEYWORDSitself.- Stop words and fallback:
test/mcp-size.test.tshas a direct unit test for dropping filler words, keeping the words when the query is all filler, and answering with the tools that match the most words when none match all.
The commit carries a "No door:" line, since the change is test-only and adds nothing new for the terminal.
Earlier asks are met: the test now goes through the real tools/call path, KEYWORDS keys and words are validated, and stop-word and fallback behaviour has a direct unit test. Tests pass here and the preview answers 200. No security, door or README concerns; no ceilings raised and no new tool. Non-blocking: QUESTIONS is exported from a test file, so it can be unexported.
find_toolnow ranks the right tool first for 23 plain-words questions, and a new test keeps it that way.test/mcp-size.test.ts,test/mcp-tools.test.ts,test/mcp-doc-matches-tools.test.ts, the new test and the type check pass;scripts/gate.ts --fixreported rewrapped comments, which are in the commit. I did not run the full suite.Why it missed.
find_toolrequired every word of the query to appear in a tool's name or description. "make a copy of this app" matched nothing, because "make" and "copy" aren't both in any description.What changed in
src/http/mcp/catalog.ts:KEYWORDStable gives a few tools plain-word synonyms. For examplemake_it_yoursgets "copy",asksgets "waiting", andpreviewgets "failed". These are matched like description words but never sent to clients, so they cost nothing against the size ceilings. I added no tool and did not raise any ceiling.The test.
test/mcp-find-tool-queries.test.tsholds a table of 23 questions, each mapped to the tool that must rank first. A miss fails with the query, the expected tool and the actual one. It callsmatchingon the real tool table rather than going through the MCP server.Other edits.
test/mcp-size.test.ts: I changed one assertion that was wrong under the new behaviour.matching(es, "alpha zzz")used to return[]; it now returns the tools matching "alpha", and"zzz"alone still returns[].find_tool'sdocline now describes the looser matching.Not done. There are no stemming or typo tolerance, and only the tools the 23 questions needed have keywords. A newly found miss means adding a row to the table and, if needed, to
KEYWORDS.Try it. Run
bun test test/mcp-find-tool-queries.test.ts, or callfind_toolwith{"query":"what is waiting on me"}and seeasksfirst.The pre-push hook demanded a
Try:line in a commit message, so I added an empty commit for it.Closes #14702