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); failed calls free. Reads or computes only and changes nothing; each call is charged, so repeats are not free.

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

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?

Annotations already cover read-only and non-destructive behavior, and the description adds real value on top: per-document and total truncation limits (2,000 chars each, 40,000 total), result ordering, and pricing ($0.002/call, failed calls free). It also explains why repeats cost money, which is consistent with idempotentHint=false and gives the agent a reason to avoid redundant calls.

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?

Information is front-loaded: what it does, input format and limits, return shape, then usage and pricing. It is a dense single paragraph with semicolon-chained clauses, so a reader must parse carefully, but every clause carries operational information rather than filler.

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?

With no output schema, the description fully specifies the return value (original index, score, text, best first). Combined with input limits, cost, and safety posture, an agent has everything needed to invoke and budget the call correctly.

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 the baseline is 3; the description still adds meaning by explaining that documents may be a JSON array or one-per-line and that top_n 'keeps only the best.' It does not clarify accepted types for top_n beyond the schema's string/number/boolean union, which is the one remaining ambiguity.

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 verb and resource ('Order up to 50 documents by how well each answers a query') plus the model (BAAI bge-reranker-base, cross-encoder) and score range 0-1. This is clearly a reranker, not a search or embedding tool, so it is separable from siblings like search, ai_embed, or ai_answer.

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?

Gives an explicit placement in the pipeline: 'Use to pick what a model reads after search or vector retrieval,' which tells the agent when this tool applies and implies search/embed run first. It also names an alternate interface (/v1/rerank), but does not state when to avoid reranking or how to choose between this and sibling answer/summarize tools.

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.

Resources