Skip to main content
Glama

Rerank documents by relevance: reranker for RAG

ai_rerank
Read-only

Order up to 50 documents by how well each answers a query, with a relevance score from 0 to 1 (BAAI bge-reranker-base, a cross-encoder). Send documents as a JSON array or one per line; each is read up to 2,000 characters, 40,000 in all. Returns the original index, score and text, best first; top_n keeps only the best. Also available in the Cohere-style shape at /v1/rerank. Use to pick what a model reads after search or vector retrieval. Price $0.002/call via x402 USDC or a card key (/credits), first 25 free; failed calls free. Reads or computes only and changes nothing; each call is charged, so repeats are not free.

Input Schema

NameRequiredDescriptionDefault
queryYesWhat the documents should answer (up to 2,000 characters)
top_nNoKeep only the best N results (default all)
documentsYesUp to 50 documents: a JSON array of strings, or one per line

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the annotations by disclosing truncation limits (2,000 chars per doc, 40,000 total), the 50-document cap, the return shape (index, score, text, best first), and pricing ($0.002/call, first 25 free, failed calls free). It also resolves the idempotentHint=false annotation with a concrete reason: 'each call is charged, so repeats are not free'.

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

Conciseness4/5

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

Front-loads the core operation and stays to a single dense paragraph with no filler. The pricing clause is long but earns its place because it explains the non-idempotent charging behavior; a slight tightening would push this to a 5.

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

Completeness5/5

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

There is no output schema, yet the description fully documents the return payload and ordering, plus limits, cost and side-effect profile. For a 3-parameter tool of this complexity, an agent has everything needed to call it and interpret results.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3; the description still adds real meaning by specifying per-document and total character truncation and the semantics of top_n ('keeps only the best'). The documents parameter's input encoding is already in the schema, so no further lift is needed.

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?

Opens with a specific verb+resource+metric: 'Order up to 50 documents by how well each answers a query, with a relevance score from 0 to 1', and names the underlying model (BAAI bge-reranker-base, a cross-encoder). This clearly separates it from sibling embedding/chat tools like ai_embed and ai_chat.

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

Usage Guidelines4/5

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

Explicitly states the use case: 'Use to pick what a model reads after search or vector retrieval', and points to a Cohere-style alternative endpoint at /v1/rerank. It does not spell out when NOT to rerank or contrast against sibling tools such as ai_embed, so it stops short of a 5.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.