Skip to main content
Glama

rerank_documents

Rerank documents by relevance to a query using a Cross-Encoder, returning sorted scores for better RAG and AI agent responses.

Instructions

Reranks a list of documents based on their relevance to a given query.

Args: query: The core intent or query string to compare against. documents: A list of document descriptions/strings to be ranked. model_name: The HuggingFace model name for the CrossEncoder. Default is from env RERANKER_MODEL_NAME or 'BAAI/bge-reranker-v2-m3'.

Returns: A JSON string representing a sorted list of dictionaries containing 'document' and 'score'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
documentsYes
model_nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

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

With no annotations, the description must disclose behavioral traits. It does explain that it uses a CrossEncoder, mentions the model default, and describes the return format. However, it does not mention potential side effects like model downloads, network requirements, or that scores are sorted in descending order (only says 'sorted'). These are meaningful behavioral details that are missing.

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?

The description is well-structured and efficient: a one-sentence summary, clear Args, and Returns. No wasted words, and the core purpose is front-loaded. Every sentence serves a 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?

The description covers the essential inputs, behavior, and output format for a simple reranking tool. However, it omits the sort order (ascending/descending) and potential edge cases like empty document lists. Since an output schema exists, it is mostly complete but has minor gaps.

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

Parameters5/5

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

The input schema has no descriptions (0% coverage), but the description's Args section fully compensates by explaining each parameter, including the optional model_name and its default from env or 'BAAI/bge-reranker-v2-m3'. This adds complete semantic meaning beyond the schema.

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?

The description clearly states the tool's function: 'Reranks a list of documents based on their relevance to a given query.' The verb 'reranks' is specific and the resource is clearly identified. Though no sibling tools are listed, the purpose is unambiguous and distinct.

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?

The description implies when to use the tool (when you need to rerank documents by relevance) but does not explicitly state scenarios or provide exclusions. Since there are no sibling tools, explicit alternatives are not needed, but there is no guidance on when to prefer this tool over other potential approaches.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/globalpocket/mcp-reranker'

If you have feedback or need assistance with the MCP directory API, please join our Discord server