Skip to content

feat(mcp): add tools search <query> for fuzzy tool discovery - #6317

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-6300
Jul 16, 2026
Merged

feat(mcp): add tools search <query> for fuzzy tool discovery#6317
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-6300

Conversation

@nghetienhiep

Copy link
Copy Markdown
Contributor

What

Add loopover-mcp tools search <query> (with --json) so a user or agent can find the right tool among
the combined local + remote surface without reading the full tools listing top to bottom or already
knowing the exact name. The query fuzzy-matches against each registered tool's name AND description, so
a term that only appears in a description still surfaces the tool.

Why

tools/tools --json only dump every locally-registered stdio tool in registration order — the only way
to find one is to scroll the whole list or know its exact name (confirmed in #6300; no search/filter
existed). Once the local and remote sets are unified into ~150 tools that no longer scales.

How

  • Turned tools into a small dispatcher: tools search routes to a new toolsSearchCommand, and the
    bare tools / tools --json listing behaves byte-for-byte as before (its option parsing just moved
    inside the command).
  • searchTools ranks matches best-first: a substring hit on the name beats a substring hit on the
    description, which beats a typo-tolerant hit; non-matches are dropped and ties break alphabetically for a
    stable listing.
  • Typo tolerance reuses the CLI's existing levenshteinDistance (the same utility behind
    suggestCommand's "did you mean") instead of adding a fuzzy-match dependency, per the issue's guidance.
    The edit-distance budget scales with the query length.
  • --json returns { query, count, tools }; the human view prints aligned name + description rows, or a
    friendly No tools match "<query>". line when nothing matches. Running tools search with no query
    prints a usage error.
  • Declared search in CLI_COMMAND_SPEC so tab-completion (all four shells) and the typo-suggester pick
    it up, and documented it in --help. Kept it local-CLI-only — the remote server's tool list stays a
    separate concern, as the issue scopes it.

Testing

  • New test/unit/mcp-cli-tools-search.test.ts drives the real CLI and covers a name match (ranked first),
    a description-only match (query absent from every tool name), a Levenshtein typo match, a no-match query
    (empty --json result set and the plain "No tools match" line), the human row output, and the
    missing-query usage error.
  • npm run typecheck, npm run build:mcp, npm run test:mcp-pack, and the existing
    test/unit/mcp-cli-tools.test.ts + test/unit/mcp-cli-completion-spec.test.ts suites — all green.

Closes #6300

Add a `loopover-mcp tools search <query>` subcommand (with `--json`) that
fuzzy-matches a query against each registered tool's name and description, so
a tool can be found without scrolling the full `tools` listing or knowing its
exact name. Ranks name-substring over description-substring over a
Levenshtein typo match, reusing the CLI's existing distance helper rather than
adding a dependency. Declared in the command spec so completion and the
typo-suggester pick it up, and documented in --help.

Closes JSONbored#6300
@nghetienhiep
nghetienhiep requested a review from JSONbored as a code owner July 16, 2026 01:31
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 16, 2026
@loopover-orb

loopover-orb Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-16 01:42:01 UTC

2 files · 1 AI reviewer · no blockers · readiness 88/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
The AI review returned non-blocking notes for this change but did not include a separate narrative summary. Review the nits below before deciding this PR.

Nits — 5 non-blocking
  • mcp-cli-tools-search test and the two doc-comments above `toolsSearchCommand`/`searchTools` restate the same rationale three times in the diff; consider trimming to one comment site.
  • packages/loopover-mcp/bin/loopover-mcp.js scoreToolMatch: `budget = Math.max(1, floor(needle.length/4))` allows an edit distance of 1 even for 1-3 character queries, which can surface noisy unrelated matches for very short searches — consider requiring budget 0 below some minimum query length.
  • toolsSearchCommand derives `query` via `args.find(arg => !arg.startsWith('--'))`, so a query that itself begins with `--` (e.g. searching for a literal flag-like term) can never be matched — worth a one-line note if that's an accepted limitation.
  • Add a test where the query itself starts with `--` to document the current usage-error behavior for that edge case.
  • Consider exposing the search's score/rank in `--json` output for debugging/tuning rather than only exposing the final ordering.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #6300
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 112 registered-repo PR(s), 64 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor nghetienhiep; Gittensor profile; 112 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The PR implements `tools search <query>` with `--json` support, reuses the existing levenshteinDistance utility instead of adding a dependency, matches against both name and description, and includes tests for name-match, description-match, typo-tolerance, and no-match cases as required.

Review context
  • Author: nghetienhiep
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, Vue, C#, JavaScript, C, C++, Go, Objective-C
  • Official Gittensor activity: 112 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add a concise scope and risk note.
  • Then work through the remaining 1 step in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask 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.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/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.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 44570d0 into JSONbored:main Jul 16, 2026
14 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 16, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mcp): add loopover-mcp tools search <query> for fuzzy discovery across the ~150-tool combined surface

1 participant