Skip to main content
Glama

read_chunk_neighbors

Retrieve chunks before and after a target chunk in a document to provide additional context. Use when search results need surrounding information like examples or 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–50, default 2).
afterNoNumber of chunks to retrieve after the target (0–50, default 2).
Behavior5/5

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

In absence of annotations, description fully discloses behavior: returns target with isTarget:true plus neighbors sorted ascending, clamping, defaults and max values, validation on chunkIndex, mutual exclusivity of filePath/source.

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?

Single paragraph, about 100 words, front-loaded with purpose, then details. Every sentence adds value, no redundancy.

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?

No output schema, but description explains return structure (target with isTarget, neighbors sorted). For a read tool with clear behavior, this is adequate. Could specify output fields but not critical.

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 coverage is 100%, so baseline is 3. Description adds meaningful context: explains filePath vs source usage with examples, mutual exclusivity, and default values for before/after.

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 'Expand a query_documents result by reading the chunks immediately before and after it,' with specific verb and resource. It distinguishes from sibling tools which are about ingestion, listing, and querying.

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

Usage Guidelines4/5

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

Provides explicit when-to-use guidance: 'when the hit needs more surrounding context.' Does not explicitly state when not to use, but context is clear.

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/shinpr/mcp-local-rag'

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