Skip to main content
Glama

Read File

read_file

Reads file contents, with optional line-range slicing and line numbering to inspect code and verify changes precisely.

Instructions

Read the contents of a file with optional line-range slicing and line numbering.

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_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesRelative or absolute path to the file.
end_lineNo1-indexed end line inclusive (optional).
start_lineNo1-indexed start line (optional).
line_numbersNoIf True, prefixes lines with line numbers (e.g. '12 | code').

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.1.0
    • addedInput schema / properties / end_line
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "1-indexed end line inclusive (optional)."
      +}
    • addedInput schema / properties / line_numbers
      Added value: +{
      +  "default": false,
      +  "description": "If True, prefixes lines with line numbers (e.g. '12 | code').",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / start_line
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "1-indexed start line (optional)."
      +}
  2. First observedv2.0.0

TDQS

B3.1/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full behavioral burden and does not deliver: it never says what happens on a missing path, whether large files are truncated, how binary/non-UTF8 content is handled, or that the operation is non-destructive. A single word about read-only safety and error behavior would materially help an agent plan around failures.

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?

One sentence, front-loaded with the core action, with the optional capabilities trailing. No redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple, the input schema is fully documented, and an output schema exists so return values need no explanation. However, with zero annotations the description should still cover edge-case behavior (missing file, oversized file, encoding) for an agent to invoke it reliably.

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 every parameter including the 1-indexed start_line/end_line and the line_numbers prefix format is already documented. The description merely restates the existence of slicing and numbering without adding semantics such as what happens when only start_line is given or when the range exceeds file length.

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 contents of a file") plus the two optional capabilities (line-range slicing, line numbering), so the agent knows exactly what operation this performs. It does not explicitly distinguish itself from siblings like file_info (metadata) or search_code, leaving that contrast to inference.

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

Usage Guidelines2/5

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

There is no when-to-use guidance at all: nothing says to prefer this over file_info for metadata, glob_files for locating paths, or search_code for pattern matching. The use case is only implied by the word "read."

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