Skip to content

feat: add semantic tool search#2

Merged
mKeRix merged 24 commits into
mainfrom
add-semantic-search
Nov 27, 2025
Merged

feat: add semantic tool search#2
mKeRix merged 24 commits into
mainfrom
add-semantic-search

Conversation

@mKeRix

@mKeRix mKeRix commented Nov 25, 2025

Copy link
Copy Markdown
Owner

This implements a semantic search pattern for discovering tools, combined with fuzzy matching logic to also cover direct keyword hits. This further reduces the tokens that need to be loaded into the LLM asking about available tools & also simplifies the core workflow to a single search command instead of the multiple list commands it had to do previously.

@codecov-commenter

codecov-commenter commented Nov 25, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.00665% with 478 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.83%. Comparing base (4fa23ff) to head (979b6f0).
⚠️ Report is 33 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/search/engine.ts 4.09% 211 Missing ⚠️
src/search/semantic.ts 24.43% 133 Missing ⚠️
src/gateway/server.ts 2.98% 65 Missing ⚠️
src/cli/commands/search.ts 77.27% 25 Missing ⚠️
src/search/cache.ts 81.10% 24 Missing ⚠️
src/cli/commands/gateway.ts 65.21% 8 Missing ⚠️
src/search/fuzzy.ts 91.52% 5 Missing ⚠️
src/cli/utils/types-output.ts 88.88% 4 Missing ⚠️
src/gateway/aggregator.ts 92.30% 2 Missing ⚠️
src/utils/paths.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #2      +/-   ##
==========================================
- Coverage   59.31%   52.83%   -6.48%     
==========================================
  Files          15       25      +10     
  Lines         843     1709     +866     
  Branches       62      105      +43     
==========================================
+ Hits          500      903     +403     
- Misses        343      806     +463     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @mKeRix, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a powerful semantic tool search feature to the toolscript CLI, fundamentally changing how Large Language Models (LLMs) interact with and discover available tools. By combining vector embeddings for natural language understanding with fuzzy matching for keyword hits, the system aims to significantly reduce token consumption and streamline the tool discovery process, making it more efficient and scalable.

Highlights

  • Semantic Tool Search: Introduced a new hybrid semantic and fuzzy search capability for discovering MCP tools, significantly improving tool selection accuracy for LLMs.
  • Reduced LLM Token Usage: The new search mechanism reduces the number of tokens LLMs need to process for tool discovery, streamlining the workflow.
  • New CLI Command: Added a toolscript search command that allows natural language queries and provides configurable output formats (table or TypeScript types).
  • Persistent Embedding Cache: Implemented a disk-based cache for tool embeddings, ensuring faster restarts and avoiding redundant model computations.
  • GPU Acceleration Support: The semantic search engine supports GPU acceleration (e.g., Metal on Apple Silicon, CUDA on NVIDIA) with automatic fallback to CPU.
  • Updated CLI Commands: Modified gateway start to include search configuration options and updated get-types and list-tools to use a unified filter parameter.
  • Gateway API Endpoints: Added new /search and /search/stats endpoints to the gateway for programmatic tool discovery and monitoring.
  • Comprehensive Documentation: Extensive documentation has been added and updated, including a new docs/cli.md and detailed design specifications under openspec/.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a major new feature: semantic tool search. The implementation is comprehensive, covering the search engine itself (with semantic and fuzzy components), caching, CLI commands, gateway endpoints, and extensive documentation. The code is well-structured and the feature is well-designed with graceful degradation.

I've found a few issues:

  • A deprecated transitive dependency has been introduced in deno.lock.
  • The example code generated by the new search command and the updated get-types command is incorrect because it doesn't convert server/tool names to camelCase, which will lead to runtime errors for users who copy the examples.

Overall, this is a great addition. Addressing these issues will make it even better.

Comment thread src/cli/commands/search.ts Outdated
Comment thread deno.lock
Comment thread src/cli/commands/types.ts Outdated
@mKeRix mKeRix force-pushed the add-semantic-search branch from 7e10536 to b1024a2 Compare November 25, 2025 23:32
Temporary - to fix an issue on macOS with the underlying onnxruntime-node.
@mKeRix mKeRix force-pushed the add-semantic-search branch 3 times, most recently from b327a1e to 4753ca9 Compare November 27, 2025 09:09
@mKeRix mKeRix force-pushed the add-semantic-search branch from 4753ca9 to 126f2cd Compare November 27, 2025 09:11
@mKeRix mKeRix force-pushed the add-semantic-search branch from 711c1f4 to 9544602 Compare November 27, 2025 16:12
@mKeRix

mKeRix commented Nov 27, 2025

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a major new feature: a hybrid semantic and fuzzy search engine for tool discovery. This is a significant enhancement that improves the developer experience and LLM efficiency by moving from manual listing to natural language search. The implementation is well-structured, with clear separation of concerns into new modules for the search engine, caching, and CLI commands. The changes also include comprehensive documentation, specifications, and E2E tests. My review found a couple of medium-severity issues: a minor documentation inconsistency for a CLI flag and a potential performance optimization in the cosine similarity calculation. Overall, this is an excellent contribution that greatly improves the project's capabilities.

Comment thread src/cli/commands/gateway.ts
Comment thread src/search/semantic.ts
@mKeRix mKeRix merged commit cac523b into main Nov 27, 2025
1 check passed
@mKeRix mKeRix deleted the add-semantic-search branch November 27, 2025 23:13
github-actions Bot pushed a commit that referenced this pull request Dec 1, 2025
# 1.0.0 (2025-12-01)

### Features

* add config merging ([#5](#5)) ([4d58cb7](4d58cb7))
* add semantic tool search ([#2](#2)) ([cac523b](cac523b))
* allow filtering exposed tools ([#4](#4)) ([bd1d64c](bd1d64c))
* implement code mode ([#1](#1)) ([b3c4646](b3c4646))
* initial commit ([5477138](5477138))
* support oauth2 protected mcp servers ([#3](#3)) ([f5408d1](f5408d1))
github-actions Bot pushed a commit that referenced this pull request Dec 1, 2025
# 1.0.0 (2025-12-01)

### Features

* add config merging ([#5](#5)) ([4d58cb7](4d58cb7))
* add semantic tool search ([#2](#2)) ([cac523b](cac523b))
* allow filtering exposed tools ([#4](#4)) ([bd1d64c](bd1d64c))
* implement code mode ([#1](#1)) ([b3c4646](b3c4646))
* initial commit ([5477138](5477138))
* support oauth2 protected mcp servers ([#3](#3)) ([f5408d1](f5408d1))
@github-actions

github-actions Bot commented Dec 1, 2025

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants