Skip to main content
Glama
MCP Server RAG

MCP Server RAG

by atengk

rag_index_directory

Batch-ingests all files from a local directory into a knowledge base, with recursive scanning and a max_files cap to prevent timeouts on large folders.

Instructions

批量扫描并摄取本地目录下的所有文件,支持递归遍历与 max_files 超时防御截断。

Args:
    kb_name: 目标知识库名称
    dir_path: 目标目录绝对或相对路径
    glob_pattern: 匹配文件模式(默认为 "**/*")
    max_files: 目录文件摄取上限,防止大目录导致 MCP 响应超时(默认 200)
    recursive: 是否递归扫描子目录(默认 True)

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>",
      "dir_path": "<dir_path>"
    },
    "name": "rag_index_directory"
  }
}

Input Schema

NameRequiredDescriptionDefault
kb_nameYes
dir_pathYes
max_filesNo
recursiveNo
glob_patternNo**/*

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior3/5

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

The description provides no annotations, so it must disclose behavior itself. It does add useful context that the schema cannot express: max_files is a defensive truncation against MCP response timeouts on large directories, and recursive defaults to True. However, it does not state what happens when a directory is re-ingested, whether files are overwritten or duplicated, or what happens when the path does not exist.

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 summary sentence comes first and states the key behaviors, such as recursion and the max_files truncation, and it is followed by a clean Args list. The restated defaults duplicate the schema slightly, but they are justified because the schema documentation is empty.

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?

Because an output schema exists, the description does not need to enumerate return fields, and the brief '统计报告' note is sufficient. For a mutating ingest tool with no annotations, however, it should do more to describe side effects and idempotency and to explain what happens if the directory or the knowledge base is invalid.

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 full burden here; it does so reasonably well by explaining the meaning of kb_name, dir_path, glob_pattern, max_files, and recursive, including their defaults and the rationale for max_files. It falls short only in that it gives no syntax guidance or examples for glob_pattern beyond the "**/*" default.

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 and resource: it batch-scans and ingests all files in a local directory. The directory-level scope implicitly distinguishes this tool from the single-item siblings rag_index_file, rag_index_text, and rag_index_url.

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 implied by the term 'batch directory ingestion', but the description does not say when this tool should be used instead of rag_index_file or a series of per-file calls. It also omits prerequisites, such as whether kb_name must already exist via rag_create_kb.

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