Skip to main content
Glama
zongzi-zongzhi

local-Rag

read_chunk_neighbors

Retrieve surrounding chunks around a target chunk in a document to add context, such as a definition with its example or a conclusion with its reasoning.

Instructions

Expand a query_documents result by reading the chunks immediately before and after it in the same document. Use when the hit needs more surrounding context 鈥?for example, a definition without its example, or a conclusion without its reasoning. Pass chunkIndex from the query_documents result, along with the document's filePath (from ingest_file) or source (from ingest_data). Returns the target chunk (isTarget: true) plus neighbors, sorted ascending by chunkIndex. The before/after window is clamped to the document's existing chunks; a chunkIndex beyond the document returns an empty result. Defaults: before=2, after=2 (max 50 each). Provide exactly one of filePath or source.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathNoAbsolute path to the file (for documents ingested via ingest_file). Example: "/Users/user/documents/manual.pdf". Provide either filePath or source, not both.
sourceNoSource identifier used in ingest_data (for data ingested via ingest_data). Examples: "https://example.com/page", "clipboard://2024-12-30". Provide either filePath or source, not both.
chunkIndexYesZero-based target chunk index (non-negative integer).
beforeNoNumber of chunks to retrieve before the target (0鈥?0, default 2).
afterNoNumber of chunks to retrieve after the target (0鈥?0, default 2).
Behavior5/5

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

No annotations provided, so description fully carries the burden. Discloses return format (target with isTarget: true plus neighbors sorted ascending), edge-case behavior (window clamped to existing chunks, chunkIndex beyond returns empty result), and parameter defaults/ranges (before/after defaults 2, max 50). No contradictions.

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 description is front-loaded with purpose and usage, followed by technical details. It is moderately long but every sentence adds value. Minor redundancy: 'Provide exactly one of filePath or source' is stated twice (once in schema description and once in tool description), which is acceptable. Could be slightly more concise, but structure is clear.

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?

Given 5 parameters, no output schema, and no annotations, the description covers all necessary context: input sources, parameter relationships, default behavior, edge cases (empty result), and return structure. No gaps identified.

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 100%, but description adds meaning: explains that filePath and source are mutually exclusive, that chunkIndex comes from query_documents result, and that before/after have defaults and maximums. This goes beyond the schema's minimal descriptions.

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+resource: 'Expand a query_documents result by reading the chunks immediately before and after it in the same document.' It clearly distinguishes from sibling tools like query_documents (which returns hits) and ingest_file/ingest_data (which add documents). The tool is uniquely for getting neighboring context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use guidance: 'Use when the hit needs more surrounding context – for example, a definition without its example, or a conclusion without its reasoning.' It also specifies how to pass parameters (chunkIndex from query_documents result, filePath from ingest_file or source from ingest_data) and gives constraints (defaults before=2, after=2, max 50 each, provide exactly one of filePath or source).

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zongzi-zongzhi/local-Rag'

If you have feedback or need assistance with the MCP directory API, please join our Discord server