Skip to main content
Glama

mcp-reranker

一个通用的 模型上下文协议 (MCP) 服务器,使用 sentence-transformers 提供文档重排序功能。

该服务器旨在作为一个独立工具,可供任何兼容 MCP 的客户端(如 Roo Code、Claude Desktop 或自定义代理)使用,以提高 RAG(检索增强生成)的精度,或通过对查询与多个候选文档之间的相关性进行评分来帮助代理做出更好的决策。

特性

  • 交叉编码器 (Cross-Encoder) 重排序:利用 sentence-transformers 中的 CrossEncoder 模型进行高精度的相关性评分。

  • 项目无关:完全独立于任何特定的应用程序逻辑。

  • 可定制模型:支持各种 HuggingFace 模型。您可以通过环境变量配置默认模型(默认为 BAAI/bge-reranker-v2-m3)。

  • JSON 输出:以结构化的 JSON 格式返回排序后的结果。

Related MCP server: ragi

工具

rerank_documents

计算文档列表相对于给定查询的相关性得分,并按得分排序返回。

参数:

  • query (string):搜索查询或要比较的核心意图。

  • documents (array of strings):要排序的文档描述或文本列表。

  • model_name (string, optional):HuggingFace 模型标识符。默认为 RERANKER_MODEL_NAME 环境变量或 "BAAI/bge-reranker-v2-m3"。

响应示例: JSON 格式的字符串:

[
  { "document": "The most relevant document text.", "score": 0.985 },
  { "document": "A partially relevant text.", "score": 0.452 },
  { "document": "Completely irrelevant text.", "score": 0.012 }
]

安装与使用

使用 uvx 运行

将以下内容添加到您的 MCP 配置中(例如 brownie_core_mcp_config.json)。 您可以通过设置 RERANKER_MODEL_NAME 环境变量来自定义所使用的模型。

{
  "mcpServers": {
    "mcp-reranker": {
      "command": "uvx",
      "args": [
        "--from",
        "git+[https://github.com/globalpocket/mcp-reranker.git](https://github.com/globalpocket/mcp-reranker.git)",
        "mcp-reranker"
      ],
      "env": {
        "RERANKER_MODEL_NAME": "BAAI/bge-reranker-v2-m3"
      }
    }
  }
}

开发

先决条件

  • Python 3.10+

  • uv

设置

git clone [https://github.com/globalpocket/mcp-reranker.git](https://github.com/globalpocket/mcp-reranker.git)
cd mcp-reranker
uv sync --extra dev

运行测试

uv run pytest

许可证

MIT 许可证

Available Tools

1 tool
rerank_documentsA

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'.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
documentsYes
model_nameNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
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.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev0.1.2
    • First observedrerank_documents

TDQS

A4.2/5.0

Scored across 1 tool

Disambiguation5/5

Only one tool exists, so there is no possibility of confusion or overlap. The tool's purpose is clearly defined and distinct.

Naming Consistency5/5

The single tool name 'rerank_documents' follows a clear verb_noun convention and is descriptive. With only one tool, consistency is inherently maintained.

Tool Count3/5

The server has only one tool, which is at the low end of acceptable scope. While it fulfills its core reranking purpose, the count feels thin for a general utility server.

Completeness5/5

The tool fully covers the domain of reranking documents against a query. No additional operations are necessary for the stated purpose, making the surface complete.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    MCP Server for ZeroEntropy collections, top documents and rerankers
    -
  • A
    license
    A
    quality
    D
    maintenance
    Local-first RAG indexing and semantic search MCP server. Enables document retrieval and context-aware queries using local embedding models.
    3
    13 npm
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol (MCP) server that provides powerful RAG (Retrieval-Augmented Generation) capabilities for PDF documents. This server uses ChromaDB for vector storage, sentence-transformers for embeddings, and semantic chunking for intelligent text segmentation.
    MIT