Skip to main content
Glama
MCP Server RAG

MCP Server RAG

by atengk

rag_search

Performs hybrid semantic and keyword search across one or multiple knowledge bases, returning ranked text chunks with metadata and optional filters or context expansion.

Instructions

在指定知识库或跨多个知识库中执行向量语义检索与原生 FTS 倒排混合检索(RRF 融合)。

Args:
    kb_name: 目标知识库名称,支持单库名称、知识库列表(如 ["docs", "code"])或 "*" 跨全库召回
    query: 检索查询文本
    top_k: 返回相似切片的最大数量(默认为 5)
    threshold: 相似度截断阈值,过滤掉低于此分数的切片(范围 0.0 ~ 1.0)
    keyword: 可选的精准关键词,切片正文必须包含此词(大小写无关)
    metadata_filter: 可选的元数据字典过滤条件(如 {"category": "tech"})
    expand_context: 邻近上下文窗口扩展步数(默认 0 不展开,允许安全范围 0 ~ 5)

Returns:
    list[dict[str, Any]]: 排序后的相似切片列表,
        每个切片包含 chunk_id, text, score, metadata(含结构化 images 列表), kb_name

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": {
      "kb_name": "<kb_name>",
      "query": "<query>"
    },
    "name": "rag_search"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYes
top_kNo
kb_nameYes
keywordNo
thresholdNo
expand_contextNo
metadata_filterNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

With no annotations supplied, the description carries the full behavioral burden and does reasonably well: it discloses the hybrid ranking approach (vector + FTS with RRF fusion), that threshold truncates low-scoring chunks, and that expand_context widens the returned window within a bounded 0-5 range. It does not state side effects, prerequisites (e.g. whether the KB must be indexed), or latency/cost characteristics, which leaves a gap for a no-annotation tool.

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?

The definition is front-loaded with the core purpose, then uses a conventional Args/Returns layout that is easy to scan, with no filler sentences. The Returns block is somewhat redundant given that an output schema exists, and repeating it costs a few lines that could have been spent on sibling routing.

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?

For a 7-parameter tool with no annotations, the description covers all inputs including defaults and bounds, and it names the return fields (chunk_id, text, score, metadata with images, kb_name) even though the output schema already defines them. What is missing for full completeness is operational context such as prerequisites for a KB to be searchable and how this differs from the context-expanding sibling.

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?

Schema description coverage is 0%, so the description must supply all parameter meaning, and it does: every one of the seven parameters is explained with accepted value forms, defaults, value ranges, and concrete examples (list vs '*' for kb_name, 0.0-1.0 for threshold, {"category": "tech"} for metadata_filter, case-insensitive matching for keyword). This is substantially more than the bare JSON schema conveys.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The first sentence names a specific verb and resource and goes further by naming the retrieval mechanism (vector semantic search combined with native FTS inverted-index search, RRF fusion), so the agent knows exactly what kind of operation this is. It falls short of a 5 because it never distinguishes itself from the sibling `rag_query_with_context`, which an agent could plausibly reach for instead.

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?

Usage is only implied by the retrieval framing; there is no explicit when-to-use or when-not-to-use statement and no routing to `rag_query_with_context` or `rag_list_kbs`. Some scoping guidance is embedded in the kb_name parameter ('*' for cross-KB recall), which helps an agent choose the call shape but is not the same as tool-level guidance.

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