Skip to main content
Glama

Read file

read_file
Read-onlyIdempotent

Read a text file from a repository, optionally a line range, and from the working tree or a specific commit to compare before/after changes.

Instructions

Read a text file from the repository, optionally a line range, either from the working tree or at a specific commit (ref). Use ref to compare a file before and after a change. Output is capped; if truncated is true, request a later startLine.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoCommit, branch or tag to read from. Omit to read the working tree.
pathYesRepo-relative path, e.g. `src/index.ts`.
endLineNoLast line to return (inclusive).
startLineNoFirst line to return (1-based).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
refYesResolved commit SHA, or null for the working tree.
pathYes
contentYes
endLineYesLast line actually returned.
isBinaryYes
startLineYes
truncatedYes
totalLinesYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent and non-destructive, so safety is covered. The description adds real behavioral context the annotations lack: output is capped, a `truncated` flag is returned, and the caller should re-request with a later `startLine`. It omits error behavior (missing path, binary files), which keeps it below a 5.

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?

Two sentences, zero filler, and the most important scoping fact (working tree vs. ref) is front-loaded. Every clause carries information the caller needs.

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 spelled out, and the description covers the one non-obvious runtime behavior (capping and the `truncated` recovery path). Nothing required to call it correctly is missing.

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

Parameters4/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds semantics beyond the schema by explaining what `ref` is for (comparing a file before and after a change) and by tying `startLine` to the truncation-recovery loop, which the schema's bare 'First line to return' does not convey.

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+resource ('Read a text file from the repository') plus the two axes of scope: working tree vs. a specific commit, and an optional line range. It implicitly separates itself from search_code and get_diff by framing ref as a way to see a file's state rather than a change set, though it never names a sibling explicitly.

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 `ref` to compare a file before and after a change' gives a concrete usage condition, and the truncation sentence tells the agent how to recover. It lacks explicit exclusions or named alternatives (e.g., 'use search_code to find a file'), 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.

Deploy Server

Other Tools