Skip to main content
Glama

Okapi BM25 + Reciprocal Rank Fusion (RRF) + MMR Chunk Reranker

rerank_hybrid_rag_chunks
Read-onlyIdempotent

Rerank and deduplicate candidate RAG passages against a query using BM25, RRF, and MMR scoring to select top-K high-signal, non-redundant chunks from vector or grep results.

Instructions

Reranks and deduplicates candidate RAG or retrieval passages against a search prompt using Okapi BM25 (k1=1.5, b=0.75), Reciprocal Rank Fusion (RRF), and Maximal Marginal Relevance (MMR) Jaccard diversity filtering. Use when selecting the top-K highest-signal, non-redundant passages from vector search or grep results; for compressing a single contiguous source file while keeping its original line order, use prune_context_skeleton instead. Read-only edge call (32 KB, 60 RPM): accepts 'search_prompt' ('documents_json' defaults to 'standard'), uses '?demo=true' or L402 (15 sats); HTTP 400 if invalid.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>",
      "documents_json": "<documents_json>"
    },
    "name": "rerank_hybrid_rag_chunks"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesTechnical search query or question used to score candidate chunks.
top_kNoMaximum number of deduplicated chunks to return; defaults to 5 when omitted.
ranking_modeNoFusion weighting between lexical BM25 and diversity penalty; defaults to 'bm25_rrf_mmr' when omitted.
documents_jsonYesJSON string or array of candidate chunks '[{"id":"c1","text":"..."}]' to rerank.

Output Schema

NameRequiredDescriptionDefault
queryYesEvaluated search query.
ranked_chunksYesOrdered top-K chunks with bm25_score, rrf_score, and mmr_score.
returned_countYesNumber of deduplicated top-K chunks returned.
total_candidatesYesNumber of input candidate chunks scored.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.6.0
    • addedInput schema / properties / query
      Added value: +{
      +  "description": "Technical search query or question used to score candidate chunks.",
      +  "type": "string"
      +}
    • removedInput schema / properties / search_prompt
      Removed value: -{
      -  "description": "Technical search prompt or question used to score candidate chunks.",
      -  "type": "string"
      -}
    • changedInput schema / required
      Previous value: -[
      -  "search_prompt",
      -  "documents_json"
      -]New value: +[
      +  "query",
      +  "documents_json"
      +]
  2. Addedv1.3.3

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover readOnly/idempotent/non-destructive, and the description still adds real operational context: 32 KB payload limit, 60 RPM throttling, L402 payment at 15 sats, a ?demo=true escape hatch, and HTTP 400 on invalid input. The '32 KB' figure is ambiguous (request size vs. response cap), which keeps this short of a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and the sibling exclusion are properly front-loaded, but the single run-on sentence crams in tuning constants (k1=1.5, b=0.75) that give an agent little decision value, and the trailing clause compounds the parameter-name confusion rather than resolving it.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return-value explanation is rightly omitted, and the description covers cost, auth, error behavior, and the alternative tool for a moderately complex 4-param reranker. The one substantive gap is that its parameter naming does not match the actual schema, which is exactly the information an agent needs to invoke it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline would be 3, but the description actively misleads: it names a parameter 'search_prompt' that does not exist (the schema has 'query') and claims 'documents_json' 'defaults to standard' when the schema marks it required and typed as a JSON string/array. The real optional parameters ('top_k', 'ranking_mode') are never discussed, so the description subtracts rather than adds.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Specific verb+resource: 'reranks and deduplicates candidate RAG or retrieval passages' with the exact algorithm stack (BM25, RRF, MMR Jaccard) named. It also explicitly distinguishes itself from the closest sibling, prune_context_skeleton, so an agent can route without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

'Use when selecting the top-K highest-signal, non-redundant passages from vector search or grep results' gives the triggering condition, and 'for compressing a single contiguous source file while keeping its original line order, use prune_context_skeleton instead' gives the exclusion plus the alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools