Repository navigation
feat(mcp): expose semantic_search tool on the MCP server - #1681
shaktimaan00 wants to merge 4 commits into
Conversation
## Proposed Changes - Add `AGENTS.md` with repository structure, development commands, coding conventions, testing guidance, and commit/PR expectations. - Add an English `DESIGN.md` following the design.md alpha specification, documenting React Bootstrap as the design foundation and the default primary color `#0033FF`. - Document existing theme overrides, dark mode, layout conventions, and component usage, with YAML design tokens and source references. ## Validation - Checked commands and conventions against repository configuration and source files. - Confirmed `DESIGN.md` contains no Chinese text. - `git diff --cached --check` passed before committing. - Documentation-only changes; no application tests run.
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.
|
Thanks for the PR. Before exposing this handler through MCP, please apply the same visibility checks used by the existing MCP handlers. Please also resolve the conflicts with |
The vector index keeps every synced record, so a question hidden or deleted after the sync was still returned by semantic_search, and answers/comments were read without a status check. Gate every result on the parent question with mcpQuestionIsPublic, the same check the other MCP handlers use, and skip answers and comments that are no longer available.
|
Both points are addressed. Visibility. Conflicts. Merged Gates on the merged tree, in a container:
One thing I did not add: a handler-level unit test for the new filtering. |
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.