Skip to main content
Glama
MCP Server RAG

MCP Server RAG

by atengk

rag_index_file

Index a local file into a knowledge base by detecting its format, splitting content structurally, generating vector embeddings, and skipping unchanged files via SHA-256 checks.

Instructions

摄取本地单个文件,自动识别文件格式并进行结构感知切片、向量嵌入与持久化索引。

支持 SHA-256 内容指纹校验与幂等更新(若文件未修改则秒级跳过)。

Args:
    kb_name: 目标知识库名称
    file_path: 本地文件绝对或相对路径
    metadata: 可选的附加结构化元数据(标签、分类等)

Returns:
    dict[str, Any]: 索引结果状态字典

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>",
      "file_path": "<file_path>"
    },
    "name": "rag_index_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
kb_nameYes
metadataNo
file_pathYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description does real work: it discloses format auto-detection, structure-aware chunking, SHA-256 fingerprinting and idempotent skip-if-unchanged behavior, which is valuable for a write operation. However it omits key mutation semantics — whether an existing document is overwritten or versioned, whether a missing kb_name errors or auto-creates, and any file size or permission constraints.

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?

Front-loaded summary sentence followed by the idempotency guarantee, then a clean Args block. The Returns line restates an existing output schema and is slightly redundant, which is the only wasted content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need no prose, and all three parameters are explained. What is missing for a no-annotation write tool is the prerequisite/side-effect picture: dependency on a pre-existing knowledge base, supported formats, and overwrite behavior.

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 description coverage is 0%, so the description must carry the load, and it does: kb_name is identified as the target knowledge base, file_path as a local path accepting absolute or relative form, and metadata is flagged as optional structured tags/classification. Only the accepted metadata keys remain unspecified.

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?

States a specific verb and resource: ingest a single local file, with auto format detection, structure-aware chunking, embedding and persistent indexing. The scope word '单个文件' implicitly separates it from rag_index_directory, rag_index_url and rag_index_text, though no sibling is named explicitly.

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?

Single-file scope implies when to reach for this rather than the directory/URL/text variants, but the description never names those alternatives or states exclusions. No prerequisites are given, such as whether the knowledge base must already exist (rag_create_kb is a sibling).

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