Skip to main content
Glama

Read Text File

read_text_file
Read-only

Read a file's contents as text, including optional head or tail line limits. Handles text encodings and returns detailed errors when a file in an allowed directory cannot be read.

Instructions

Read the complete contents of a file from the file system as text. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file. Use the 'head' parameter to read only the first N lines of a file, or the 'tail' parameter to read only the last N lines of a file. Operates on the file as text regardless of extension. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
headNoIf provided, returns only the first N lines of the file
pathYes
tailNoIf provided, returns only the last N lines of the file

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so safety is covered. The description adds real value beyond that: encoding handling, detailed error messages on failure, and the constraint 'Only works within allowed directories'. Return format is not described, but an output schema exists so that is acceptable.

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?

Every sentence earns its place and the core purpose is front-loaded in the first sentence. Encoding behavior, usage context, head/tail semantics, and directory constraint each add distinct information with no redundancy or filler.

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?

With an output schema present, the description needn't explain return values, and it covers encoding, errors, and the allowed-directory constraint. The one omission is explicit differentiation from the sibling read_file, which an agent must otherwise infer.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 67%. The head/tail descriptions in the description largely restate the schema's own wording rather than adding meaning. The path parameter has no schema description and the description does not clarify it either, so the gap is only partially compensated.

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 ('Read the complete contents of a file... as text') and clarifies it operates as text regardless of extension. It implicitly separates itself from read_multiple_files via 'examine the contents of a single file', but never explicitly contrasts with the ambiguous sibling read_file, so sibling differentiation is incomplete.

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?

'Use this tool when you need to examine the contents of a single file' gives clear situational context, and head/tail usage is spelled out. However, there is no explicit when-not guidance or named alternative (e.g., read_multiple_files for batches), so it stops short of full routing guidance.

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