Skip to main content
Glama

read_text_file

Read-only

Read text files with automatic encoding detection and UTF-8 conversion, including Cyrillic and legacy codebases. Paginate large files and return line counts, size, and content hash for safe edits.

Instructions

Read file with encoding auto-detection, converts to UTF-8. PREFER THIS over built-in Read for non-UTF-8 files (Cyrillic, legacy codebases). Returns totalLines and fileSizeBytes for planning the next read, and contentHash — pass that back as expectedHash on edit_file or write_file and the call fails, changing nothing, if the file moved on since you read it. Parameters: path, encoding (auto-detected), offset (1-indexed start line), limit (max lines), maxCharacters (caps output to avoid token overflow), lineNumbers (default false: prefix lines with "N", absolute numbers — use to locate lines reported by grep or encoding errors; STRIP the prefix before using text as edit_file oldText). Page files >2000 lines: {"path": "D:\src\app.pas", "offset": 1, "limit": 2000}, then offset 2001, until offset exceeds totalLines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
limitNo
offsetNo
encodingNo
lineNumbersNo
maxCharactersNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
hintNo
contentYes
endLineNo
startLineNo
truncatedNo
totalLinesYes
contentHashNo
fileSizeBytesYes
detectedEncodingNo
encodingConfidenceNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv4.5.0
    • addedOutput schema / properties / contentHash
      Added value: +{
      +  "type": "string"
      +}
  2. Addedv3.3.0
  3. Removedv2.0.1
  4. First observedv0.1.0

TDQS

A4.7/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 behavioral context beyond that: contentHash staleness detection ('the call fails, changing nothing, if the file moved on since you read it') and the returned planning fields (totalLines, fileSizeBytes). It does not explain the idempotentHint=false, but that is a minor gap against an otherwise rich disclosure.

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?

Well front-loaded: purpose, then the preferential-use rule, then output fields, then parameter semantics, then a worked pagination example. It is dense and somewhat long, but nearly every clause earns its place; only the trailing JSON example borders on excess.

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?

An output schema exists, so return values need not be fully specified, yet the description still names the key fields. Combined with annotations and the thorough parameter coverage, an agent has everything needed to call this correctly, including the concurrency contract with edit_file/write_file.

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?

With 0% schema description coverage, the description carries the full parameter burden and does so: it documents path, auto-detected encoding, 1-indexed offset, limit, maxCharacters, and the lineNumbers prefix format with the warning to strip it before reuse as edit_file oldText. This adds meaning well beyond the bare schema types.

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?

States a specific verb+resource (read file) plus a distinguishing capability (encoding auto-detection, conversion to UTF-8), and explicitly separates itself from the built-in Read for non-UTF-8 files. An agent can tell exactly what this tool is for without opening the schema.

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?

'PREFER THIS over built-in Read for non-UTF-8 files (Cyrillic, legacy codebases)' gives an explicit when-to-use condition and a named alternative. It also supplies concrete pagination guidance (page files >2000 lines with offset/limit) for large files.

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