Skip to main content
Glama

Read Text File

read_text_file
Read-onlyIdempotent

Read a file's complete contents as text, optionally limiting results to the first or last N lines, while enforcing allowed-directory access and reporting read errors.

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.

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": {
      "path": "<path>"
    },
    "name": "read_text_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
headNoIf provided, returns only the first N lines of the file
pathYesThe file to read as text. Absolute, or relative to an allowed directory; it must resolve inside the allowed directories.
tailNoIf provided, returns only the last N lines of the file

Output Schema

NameRequiredDescriptionDefault
contentYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.0

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare readOnly, idempotent, non-destructive and closed-world, so the safety profile is covered. The description adds useful behavioral detail: encoding handling, detailed error messages on failure, and a directory sandbox boundary. That is real added context, but it remains thin on error types and the shape of partial reads.

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 purpose is front-loaded and each sentence carries a distinct fact: text-only reading, error behavior, single-file scope, head/tail options, directory restrictions. Slight redundancy exists between 'Only works within allowed directories' and the schema's path constraint.

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?

For a simple read tool with an output schema and full annotation coverage, the description covers purpose, error behavior, line-limiting options, and the sandbox boundary. The only meaningful omission is the head/tail conflict rule, which is a minor gap for this complexity level.

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 100%, with head, tail, and path all documented including the allowed-directory resolution rule. The description restates head/tail in line-count terms and echoes the sandbox constraint without adding syntax, defaults, or interaction rules (e.g., what happens if both head and tail are supplied).

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?

The description opens with a specific verb and resource ('Read the complete contents of a file ... as text') and clarifies the 'as text regardless of extension' angle, which separates it from media-reading siblings. It stops short of naming adjacent tools like read_media_file or read_multiple_files, so discrimination relies on the agent inferring from 'single file' and 'as text'.

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?

It gives a clear selection cue ('when you need to examine the contents of a single file') and explains when to reach for head or tail instead of a full read. There is no explicit when-not guidance or named alternative tool, but the usage context is unambiguous.

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