Repository navigation
feat(mcp): expose semantic_search tool on the MCP server - #1681
Open
shaktimaan00 wants to merge 1 commit into
Open
shaktimaan00 wants to merge 1 commit into
shaktimaan00 wants to merge 1 commit into
Conversation
The semantic search tool, handler and availability check already existed but RegisterMCPRouter only registered the six basic tools, so external MCP clients could not use semantic search even with a VectorSearch plugin enabled. Register semantic_search next to the basic tools when a VectorSearch plugin is available, matching how the AI chat tool list hides the tool when it cannot succeed. The registration is split into addMCPTools so the conditional is covered by a test without a live plugin registry.
This branch has not been deployed
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.
Fixes #1674
Proposed Changes
internal/router/mcp_router.go: registersemantic_searchon the public MCP server whenMCPController.SemanticSearchAvailable()reports a VectorSearch plugin, so external MCP clients (Claude Desktop, Cursor, …) can use the capability that already existed for the AI chat. The tool is registered last, after the six basic tools, and stays invisible on sites without a VectorSearch plugin — no tool that can never succeed is advertised.s.AddToolcalls move intoaddMCPTools(s, c, semanticSearchAvailable bool). The bool seam exists for the same reasonAIController.buildOpenAIToolstakes one (fix(ai): stop advertising semantic_search when no vector search plugin is enabled #1597):SemanticSearchAvailable()reads the process-wide plugin registry (plugin.IsVectorSearchEnabled()), which a unit test cannot switch on without a live plugin.internal/router/mcp_router_test.go(new): regression coverage for the conditional, in the shape ofinternal/controller/ai_tools_test.go.Acceptance criteria
The issue asks for the tool to be registered on the MCP server conditionally, and to stay hidden without a VectorSearch plugin:
semantic_searchalongside the six basic tools —TestAddMCPToolsRegistersSemanticSearchWhenAvailable.semantic_searchis not registered and the six basic tools still are —TestAddMCPToolsOmitsSemanticSearchWhenUnavailable(asserts exactly 6 tools).mcp_tools.NewSemanticSearchTool()andMCPController.MCPSemanticSearchHandler()are used as they are.Validation
Run in a
golang:1.25-bookwormcontainer againstmainat 9e6ca4a:The new test is not vacuous: forcing the gate to
falsefails the available-case test, and forcing it totruefails the unavailable-case test.make lintitself needs Docker or Podman inside the runner forscript/check-asf-header.sh, so it could not run here; that script was checked by diffing the ASF header of the two touched files against their neighbours (identical), and golangci-lint was run directly instead.No frontend change, so no screenshot.