Skip to main content
Glama
mcp-ml-tools
by adeoluo

BM25 search

bm25_search
Read-onlyIdempotent

Index inline or directory documents with Okapi BM25 and retrieve top-k results with scores, matched terms, and snippets for keyword search.

Instructions

Builds an Okapi BM25 index over documents passed inline and/or loaded from a directory inside the configured documentRoot, then returns the top-k documents with scores, matched terms, and snippets. Disk access is disabled unless documentRoot is configured.

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>"
    },
    "name": "bm25_search"
  }
}

Input Schema

NameRequiredDescriptionDefault
bNoLength normalization (default 0.75)
k1NoTerm frequency saturation (default 1.2)
topKNoResults to return (default 5)
queryYesSearch query
directoryNoDirectory relative to documentRoot to load .txt/.md files from
documentsNoInline documents to index

Output Schema

NameRequiredDescriptionDefault
hitsYes
queryYes
skippedYes
documentCountYes
vocabularySizeYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.2

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint and a closed world, so the safety profile is covered. The description adds a genuinely non-obvious operational constraint — disk access is disabled unless documentRoot is configured — which an agent would otherwise only discover by failing, and it summarizes the response contents. It does not say what happens when neither source is supplied, which keeps it below 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.

Conciseness5/5

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

Two sentences, no filler: the first covers the operation, its inputs, and its outputs; the second carries the single most important operational caveat. The documentRoot restriction is placed last where it reads as a precondition rather than burying the main purpose.

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?

With six parameters fully described in schema, an output schema present, and annotations covering safety, the description needs only to add the cross-cutting behavior — which it does via the documentRoot caveat. The one remaining gap is the empty-input case (no documents and no directory), which an agent must guess at.

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

Parameters3/5

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

Schema description coverage is 100%, so every parameter including k1, b, topK and directory is already documented in the schema. The description only reinforces that documents and directory may be combined and that directory paths resolve inside documentRoot, adding little beyond what the structured fields already state. Baseline 3 is appropriate.

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?

States a specific algorithm and resource ('Okapi BM25 index over documents'), the two input sources (inline documents and/or a directory), and the return shape (top-k with scores, matched terms, snippets). Nothing about this overlaps with siblings like tokenize or eval_compare, so an agent can route to it without opening the schema.

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

Usage Guidelines3/5

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

Usage is only implied: the description makes clear this is document retrieval ranked by BM25, so an agent can infer when ranking-style search applies. It never states when not to use it, nor does it contrast with the other available tools or explain which source (inline vs directory) to prefer.

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