Skip to main content
Glama

rerank

Read-onlyIdempotent

Rank precomputed document embeddings against a query embedding using deterministic similarity metrics to return the most relevant documents first.

Instructions

Rank caller-supplied document embeddings against a query embedding with a supported deterministic similarity metric (default embeddings.cosine_similarity), most relevant first. This tool does not embed text — call embeddings first to produce the query and document vectors. Every document embedding must share the query's dimension or the call fails with invalid_embedding_dimensions. Read-only and deterministic. Returns ranked items with rank (starting at 1) and score, plus total_documents and returned_documents counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelNoSimilarity model id from list_models; selects the metric.embeddings.cosine_similarity
top_nNoOptional cap on how many top-ranked documents are returned; omit to return all documents ranked.
documentsYesCandidate documents to rank against the query vector.
query_embeddingYesQuery vector every document embedding is scored against.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv0.1.3
    • addedInput schema / properties / documents / description
      Added value: +"Candidate documents to rank against the query vector."
    • addedInput schema / properties / documents / items / properties / embedding / description
      Added value: +"Document vector; length must equal query_embedding's."
    • addedInput schema / properties / documents / items / properties / id / description
      Added value: +"Caller-assigned document identifier, echoed back."
    • addedInput schema / properties / documents / items / properties / metadata / description
      Added value: +"Optional document metadata echoed back in the ranking."
    • addedInput schema / properties / documents / items / properties / text / description
      Added value: +"Optional document text echoed back in the ranking."
    • addedInput schema / properties / model / description
      Added value: +"Similarity model id from list_models; selects the metric."
    • addedInput schema / properties / query_embedding / description
      Added value: +"Query vector every document embedding is scored against."
    • addedInput schema / properties / top_n / description
      Added value: +"Optional cap on how many top-ranked documents are returned; omit to return all documents ranked."
  2. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

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

Beyond the annotations (readOnlyHint, idempotentHint, destructiveHint), the description adds genuinely useful behavioral context: the operation is deterministic, failure occurs with invalid_embedding_dimensions when dimensions differ, and the response includes rank starting at 1, score, total_documents, and returned_documents counts.

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 compact and front-loaded: purpose first, then the prerequisite, then the failure condition, then return shape. Every sentence earns its place, and there is no repetition of schema content.

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?

Despite having no output schema, the description explains return values, the failure mode, and the prerequisite workflow. For a 4-parameter tool with full schema coverage, this is complete enough for an agent to invoke it correctly without additional context.

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 the baseline of 3 applies. The description reinforces the relationship between query_embedding and documents (shared dimension) and mentions the default metric, but it does not need to add much because the schema already documents all four parameters thoroughly.

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 opens with a specific verb ('Rank') and a precise resource ('caller-supplied document embeddings against a query embedding'), making the tool's function immediately clear. It also differentiates itself from the sibling 'embeddings' tool by explicitly stating it does not embed text.

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?

The description gives clear when-to-use guidance by instructing the caller to invoke 'embeddings first' to produce vectors, and it warns about the dimension-matching prerequisite. It does not explicitly name alternative ranking/similarity siblings like embedding_similarity or score, so exclusion guidance is slightly implicit, but the primary workflow is well defined.

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