Skip to main content
Glama

read_file

Read text files as numbered lines, with line-range windows or in-file pattern search. Returns line numbers plus mtime and SHA-256 for safe concurrent edits.

Instructions

Read the text contents of a file (absolute path, file:// URI, or workspace-relative path). Use start_line/end_line to stream a slice of a large file. Each line is prefixed with a 1-based line number + tab (cat -n style) for exact range math; this gutter is display-only — strip the leading '\t' before reusing a line as an edit_file/find_replace old_string. Binary files are rejected; output is capped at 200 KiB (use line ranges on large files). The header carries the file's mtime (RFC3339Nano) and SHA-256 — pass them back as expected_mtime/expected_sha on edit_file for optimistic-concurrency checks. Pass pattern to search WITHIN the file instead of windowing: it returns each matching line with its 1-based line number (and optional context_lines), so an over-cap file stays searchable in one tool — literal text by default (smart-case: case-insensitive when all lowercase), Go RE2 regex when use_regex; output is bounded by max_matches (default 200) and labelled when truncated. Combine pattern with start_line/end_line to restrict the search to a line window; pattern with limit is rejected.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of lines to return starting at the first line (Claude Code-style window; first line defaults to 1). Mutually exclusive with end_line. Not usable together with pattern (search mode) — use max_matches instead.
offsetNoFirst line to read, 1-based (Claude Code-style alias for start_line; start_line wins if both are given).
patternNoSearch the file for this pattern instead of returning a window: returns each matching line with its 1-based line number (and optional context), bounded output. Literal text by default; a regular expression when use_regex is true. The whole file is scanned line-by-line regardless of size, so an over-cap file stays searchable. Combine with start_line/end_line to restrict the search to that line window; not usable with limit.
end_lineNoLast line to return (1-based, inclusive). Omit to read to the end of the file.
file_pathNoAbsolute path, file:// URI, or workspace-relative path of the file to read.
use_regexNoTreat pattern as a Go RE2 regular expression. Default false — pattern is literal text. Only consulted when pattern is set.
start_lineNoFirst line to return (1-based, inclusive). Omit to start from the beginning.
max_matchesNoMaximum number of matching lines to return in search mode. Default 200. Output is truncated (and labelled) beyond this. Only consulted when pattern is set.
context_linesNoLines of context to show before and after each match (like rg -C). Default 0. Only consulted when pattern is set.
case_sensitiveNoForce case-sensitive matching for pattern. Default (omitted): smart-case — case-insensitive when pattern is all lowercase, case-sensitive otherwise. Pass false to force case-INSENSITIVE matching even for an uppercase pattern. Only consulted when pattern is set.

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed1 schema field changedv0.17.0
    • changedInput schema / properties / context_lines / maximum
      Previous value: -10New value: +50
  2. First observedv0.16.6

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden and excels: it discloses the cat -n style line-number gutter and warns that it is display-only and must be stripped before reusing as an edit_file old_string. It reveals binary-file rejection, the 200 KiB cap, the header with mtime and SHA-256 for optimistic concurrency, smart-case matching, Go RE2 regex semantics, max_matches default and truncation labeling, and that pattern+limit is rejected. This is exemplary transparency beyond the schema.

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 description is long but every sentence earns its place, with the core purpose front-loaded. It covers reading, windowing, formatting, output limits, header metadata, search mode, and option interactions in a logical progression. It loses one point for being a dense single wall of text; bullet points or short sections would improve scannability without sacrificing information.

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?

Given 10 parameters, no annotations, and no output schema, the description is remarkably complete. It explains the return format (line-number-prefixed lines, header with mtime and SHA-256), output limits, binary rejection, search-mode results with context, truncation labeling, and constraint combinations. There is no output schema to lean on, so this description fully compensates; an agent has everything needed to call the tool correctly.

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?

Although schema coverage is 100%, the description substantially enriches every parameter. It explains the meaning of the line-number prefix, the search-mode behavior of pattern (literal vs regex, smart-case, case_sensitive semantics), the default and effect of max_matches, context_lines analogized to rg -C, and the mutual-exclusion rules among limit, end_line, start_line, and pattern. This goes well beyond the baseline 3 for high schema coverage.

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 opens with a clear, specific verb and resource: 'Read the text contents of a file' with accepted path forms (absolute, file:// URI, workspace-relative). It also distinguishes the search-within-file mode from the plain windowing mode, so an agent can tell this tool apart from siblings like read_multiple_files or search_in_files without opening their schemas.

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?

The description provides clear context for when to use different options: use start_line/end_line to stream slices of large files, use pattern to search within the file instead of windowing, and use line ranges to avoid the 200 KiB output cap. It explains when pattern and limit are mutually exclusive. However, it does not explicitly name sibling alternatives or state when NOT to use this tool in favor of another (e.g., search_in_files or read_multiple_files), so it stops short of a 5.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/plumbkit/plumb'

If you have feedback or need assistance with the MCP directory API, please join our Discord server