Skip to content

MCP: add hybrid_search tool #4861

Closed

Description

@robfrank

Part of #4859.

Motivation

vector.fuse already fuses vector + full-text scores server-side (RRF/DBSF/LINEAR), but there is no single expression that also expands over graph relationships (out()/shortestPath()) before or after fusion — that requires orchestrating multiple statements, which is error-prone and unsafe for a model to hand-write (risk of unbounded traversal, missing dedup). Justification: primarily #2 unreachable-as-a-single-call orchestration, secondarily #1 ergonomic guardrail for vector.fuse syntax.

Proposed design

  • Tool name: hybrid_search
  • Input schema:
{
  "type": "object",
  "properties": {
    "database": {"type": "string"},
    "vectorIndexName": {"type": "string"},
    "queryVector": {"type": "array", "items": {"type": "number"}},
    "k": {"type": "integer", "default": 10},
    "expand": {
      "type": "object",
      "properties": {
        "edgeTypes": {"type": "array", "items": {"type": "string"}},
        "direction": {"type": "string", "enum": ["out", "in", "both"], "default": "out"},
        "maxDepth": {"type": "integer", "default": 1, "maximum": 3}
      }
    },
    "fulltextIndexName": {"type": "string"},
    "fulltextQuery": {"type": "string"},
    "fusionStrategy": {"type": "string", "enum": ["RRF", "DBSF", "LINEAR"], "default": "RRF"}
  },
  "required": ["database", "vectorIndexName", "queryVector", "k"]
}
  • Output: {results: [{rid, fusedScore, path?, properties}]}
  • maxDepth is capped server-side (hard max, e.g. 3) to prevent runaway traversal — this is the specific unsafe-if-hand-written behavior the tool guards against.
  • Permission gating: allowReads only (read-only pipeline).
  • Engine functions used: SQLFunctionVectorNeighbors/SQLFunctionVectorSparseNeighbors, SQLFunctionOut/SQLFunctionOutE (function/sql/graph/), SQLFunctionSearchIndex (fulltext.searchIndex), SQLFunctionVectorFuse.

Acceptance criteria

  • Depth-limited traversal enforced server-side regardless of client-supplied maxDepth.
  • Works with vector-only input (no fulltextQuery) and with vector+fulltext+expand combined.
  • Dedup of nodes reached via multiple paths before fusion scoring.
  • Registered in both transports; permission-gated on allowReads.
  • Tests cover: vector-only, vector+expand, vector+expand+fulltext fusion, depth-cap enforcement.
  • Docs include a worked example query and note that vector.fuse alone (via query tool) remains available for pure two-way fusion without graph expansion.

Files to touch

server/src/main/java/com/arcadedb/server/mcp/tools/HybridSearchTool.java (new), MCPHttpHandler.java, MCPStdioServer.java, tests, docs.

Dependencies

Blocked-by #4860 (vector_search) for shared vector-leg validation logic. Related to the full_text_search tool issue — the fulltext leg here calls SEARCH_INDEX directly and does not require that tool to exist, but the two should share terminology/docs.

Effort estimate

L — most orchestration surface, most edge cases (cycles, dedup, depth caps, three-way scoring).

Activity

  1. added
    enhancement
    mcp
    on Jul 2, 2026
  2. added this to the 26.8.1 milestone on Jul 2, 2026
  3. self-assigned this
    on Jul 2, 2026
  4. modified the milestones: 26.7.2, 26.8.1 on Jul 8, 2026
  5. added
    mcp
    enhancement
    and removed
    enhancement
    mcp
    on Jul 8, 2026
  6. robfrank commented on Jul 14, 2026

    @robfrank
    CollaboratorAuthor

    Blocked by #5267 (or at least: #5267 should be a conscious decision before this starts).

    ArcadeDB's full-text BM25 is scored per bucket (document frequency is bucket-scoped, average document length is type-wide - the engine documents this at LSMTreeFullTextIndex.java:547). Merging hits across buckets and ranking them globally therefore compares scores normalized against different corpora.

    This matters specifically for hybrid_search, because fusing per-bucket-scoped BM25 scores with vector similarity scores bakes that unsoundness into a second surface, where it is much harder to unwind than it is today. Today it is confined to relevance ordering; after fusion it would silently distort the fused ranking itself.

    Surfaced while building #4862 (PR #5263), where a less relevant document outranked a more relevant one until the test fixture forced BUCKETS 1. It is pre-existing (SQL's ORDER BY $score DESC has the identical exposure) and was explicitly not a blocker for #4862, but it is a live design input for this issue.

    Worth settling #5267's direction - type-wide corpus statistics, a global re-scoring pass, or an explicit best-effort contract - before the fusion strategy here is fixed.

  7. added 6 commits that reference this issue on Jul 28, 2026
  8. added a commit that references this issue on Jul 28, 2026
  9. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementmcp

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions