Skip to main content
Glama

Read file

read_file
Read-only

Read one text file in full or by line ranges, including multiple disjoint ranges, to retrieve exact content and line positions when you need a single file's data.

Instructions

Read a text file, whole or by line range (start_line/end_line, 1-based; ranges[] for several disjoint ranges of one file). Use when: you need one file's content. When truncated, call again with start_line=next_start_line. Avoid when: you need 2+ files (read_batch) or only size/mtime (get_file_info). Output: text (as preview in compact mode; preview_truncated marks a cut), first_line, last_line, total_bytes, truncated, next_start_line (when truncated). sha256 hashes the whole file and is safe as expected_sha256; text_sha256 covers only the returned text. Missing path gives not_found.

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": {
      "relative_path": "<relative_path>"
    },
    "name": "read_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
rangesNoMultiple disjoint ranges of the SAME file (max 16). Use instead of multiple read_file calls.
end_lineNoLast line (1-based, inclusive).
max_bytesNoMax bytes returned (default and max 1 MiB).
start_lineNoFirst line (1-based).
line_numbersNotrue prefixes each line with its line number (default false).
relative_pathYesWorkspace-relative ('.' = root); absolute/.. outside it rejected.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv4.5.0
    • removedInput schema / properties / line_numbers / anyOf
      Removed value: -[
      -  {
      -    "type": "boolean"
      -  },
      -  {
      -    "maximum": 1,
      -    "minimum": 0,
      -    "type": "integer"
      -  }
      -]
    • changedInput schema / properties / line_numbers / description
      Previous value: -"1 prefixes each line with its line number (default 0)."New value: +"true prefixes each line with its line number (default false)."
    • removedInput schema / properties / line_numbers / maximum
      Removed value: -1
    • removedInput schema / properties / line_numbers / minimum
      Removed value: -0
    • changedInput schema / properties / line_numbers / type
      Previous value: -"integer"New value: +"boolean"
  2. Addedv4.0.0

TDQS

A4.7/5.0
Behavior5/5

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

The annotations already establish that this is a safe read-only operation, but the description adds substantial behavioral context beyond that: truncation behavior, next_start_line recovery, compact-mode preview semantics, preview_truncated, whole-file sha256 versus returned-text text_sha256, and not_found behavior for missing paths.

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?

The description is front-loaded and tightly structured: purpose first, then when to use, when to avoid, and output semantics. Despite covering several behaviors, every sentence earns its place and there is no filler.

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?

Although there is no output schema, the description explains the returned fields, truncation indicators, continuation strategy, and hash semantics. Combined with the annotations and fully described input schema, an agent has enough information to call the tool correctly and interpret its results.

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%, so the schema already documents parameters such as ranges, start_line, end_line, max_bytes, and line_numbers. The description reinforces the 1-based line-range model and mentions ranges[] for disjoint ranges, but it does not add much parameter-level meaning beyond what the schema already provides.

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 states a specific verb and resource: read a text file, either whole or by line range, with support for multiple disjoint ranges. It also explicitly distinguishes this tool from read_batch and get_file_info, so an agent can identify when this tool is the right fit.

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?

It gives explicit 'Use when' guidance for reading one file's content and 'Avoid when' guidance naming read_batch for multiple files and get_file_info for only size or modification time. It also tells the agent to call again with start_line=next_start_line when output is truncated.

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