Skip to main content
Glama

Read

read

Retrieve file contents with intelligent caching: unchanged files return no body, modified files return only a diff, and large files can be summarized, outlined, or read by line range.

Instructions

Read a file, returning as few tokens as possible. For 2+ files, use batch_read.

The first read returns the file's full content plus a content_hash. Echo it back as known_hash on every later read: an unchanged file then answers "unchanged": true with no body, a changed one returns a unified diff, and without it the file is always sent in full. Reading also caches the file so grep, search, and batch_read can see it.

Use offset/limit to read an exact line range, for example after a large file was summarized. A read that returns only part of a file — a line range, or a summary — reports file_hash (prefixed partial:) rather than content_hash, and it cannot be redeemed as known_hash. A ranged read also returns a coverage_token: pass it back as known_hash on your next ranged read and a window you already hold answers unchanged; once the windows cover the whole file you get a claimable content_hash.

For a large or unfamiliar file, outline=true is the cheap first read: one line per class/function as <line>: <signature>, and every number is an offset you can read next. An outline is a map, not the file, so it comes back as file_hash.

is_diff marks a unified diff and truncated marks a summary. A binary file returns metadata instead of content; for images use read_image.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path (absolute, or relative to the project root). Use an absolute path for files outside the project root.
limitNoNumber of lines to return starting at `offset`.
offsetNo1-based first line for a ranged read; omit or pass 0 to start from the first line.
outlineNoReturn the file's definitions and their line numbers instead of its text. Cannot be combined with `offset`/`limit`.
max_sizeNoByte threshold above which the file is semantically summarized; recover exact lines afterward with `offset`/`limit`.
known_hashNoThe `content_hash` from your last read of this file — or the `coverage_token` from your last ranged read of it — passed back to get `"unchanged"` instead of the content re-sent. Omit only on a first read, or when you no longer hold what it vouches for.
line_numbersNoPrefix each line of a ranged read with its number. Costs about 17% more tokens; the range is in `lines` either way. Requires `offset` or `limit`.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.6.0
    • changedInput schema / properties / known_hash / description
      Previous value: -"The `content_hash` from your last read of this file; pass it\nback to get `\"unchanged\"` instead of the content re-sent. Omit only\non a first read or when you no longer hold the hash."New value: +"The `content_hash` from your last read of this file — or the\n`coverage_token` from your last ranged read of it — passed back to\nget `\"unchanged\"` instead of the content re-sent. Omit only on a\nfirst read, or when you no longer hold what it vouches for."
    • addedInput schema / properties / line_numbers
      Added value: +{
      +  "default": false,
      +  "description": "Prefix each line of a ranged read with its number. Costs\nabout 17% more tokens; the range is in `lines` either way. Requires\n`offset` or `limit`.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / outline
      Added value: +{
      +  "default": false,
      +  "description": "Return the file's definitions and their line numbers instead\nof its text. Cannot be combined with `offset`/`limit`.",
      +  "type": "boolean"
      +}
    • changedOutput schema / (root)
      Previous value: -{
      -  "properties": {
      -    "content": {
      -      "anyOf": [
      -        {
      -          "type": "string"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Content"
      -    },
      -    "content_hash": {
      -      "anyOf": [
      -        {
      -          "type": "string"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Content Hash"
      -    },
      -    "from_cache": {
      -      "anyOf": [
      -        {
      -          "type": "boolean"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "From Cache"
      -    },
      -    "hint": {
      -      "anyOf": [
      -        {
      -          "type": "string"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Hint"
      -    },
      -    "is_binary": {
      -      "anyOf": [
      -        {
      -          "type": "boolean"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Is Binary"
      -    },
      -    "is_diff": {
      -      "anyOf": [
      -        {
      -          "type": "boolean"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Is Diff"
      -    },
      -    "lines": {
      -      "anyOf": [
      -        {
      -          "properties": {
      -            "end": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "End"
      -            },
      -            "start": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Start"
      -            },
      -            "total": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Total"
      -            },
      -            "truncated": {
      -              "anyOf": [
      -                {
      -                  "type": "boolean"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Truncated"
      -            }
      -          },
      -          "title": "ReadLineRange",
      -          "type": "object"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null
      -    },
      -    "mime": {
      -      "anyOf": [
      -        {
      -          "type": "string"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Mime"
      -    },
      -    "params": {
      -      "anyOf": [
      -        {
      -          "properties": {
      -            "diff_mode": {
      -              "anyOf": [
      -                {
      -                  "type": "boolean"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Diff Mode"
      -            },
      -            "limit": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Limit"
      -            },
      -            "max_size": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Max Size"
      -            },
      -            "offset": {
      -              "anyOf": [
      -                {
      -                  "type": "integer"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Offset"
      -            },
      -            "truncated": {
      -              "anyOf": [
      -                {
      -                  "type": "boolean"
      -                },
      -                {
      -                  "type": "null"
      -                }
      -              ],
      -              "default": null,
      -              "title": "Truncated"
      -            }
      -          },
      -          "title": "ReadParams",
      -          "type": "object"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null
      -    },
      -    "path": {
      -      "anyOf": [
      -        {
      -          "type": "string"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Path"
      -    },
      -    "size": {
      -      "anyOf": [
      -        {
      -          "type": "integer"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Size"
      -    },
      -    "tokens_original": {
      -      "anyOf": [
      -        {
      -          "type": "integer"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Tokens Original"
      -    },
      -    "tokens_returned": {
      -      "anyOf": [
      -        {
      -          "type": "integer"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Tokens Returned"
      -    },
      -    "tokens_saved": {
      -      "anyOf": [
      -        {
      -          "type": "integer"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Tokens Saved"
      -    },
      -    "total_lines": {
      -      "anyOf": [
      -        {
      -          "type": "integer"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Total Lines"
      -    },
      -    "total_tokens": {
      -      "anyOf": [
      -        {
      -          "type": "integer"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Total Tokens"
      -    },
      -    "truncated": {
      -      "anyOf": [
      -        {
      -          "type": "boolean"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Truncated"
      -    },
      -    "unchanged": {
      -      "anyOf": [
      -        {
      -          "type": "boolean"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null,
      -      "title": "Unchanged"
      -    }
      -  },
      -  "title": "ReadResponse",
      -  "type": "object"
      -}New value: +null
  2. Changed6 schema fields changedv0.5.1
    • addedInput schema / properties / known_hash
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "The `content_hash` from your last read of this file; pass it\nback to get `\"unchanged\"` instead of the content re-sent. Omit only\non a first read or when you no longer hold the hash."
      +}
    • addedInput schema / properties / limit / description
      Added value: +"Number of lines to return starting at `offset`."
    • addedInput schema / properties / max_size / description
      Added value: +"Byte threshold above which the file is semantically\nsummarized; recover exact lines afterward with `offset`/`limit`."
    • addedInput schema / properties / offset / description
      Added value: +"1-based first line for a ranged read; omit or pass 0 to start\nfrom the first line."
    • addedInput schema / properties / path / description
      Added value: +"File path (absolute, or relative to the project root). Use an\nabsolute path for files outside the project root."
    • removedOutput schema / properties / semantic_match
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "title": "Semantic Match"
      -}
  3. Changed5 schema fields changedv0.4.8
    • addedOutput schema / properties / content_hash
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Content Hash"
      +}
    • addedOutput schema / properties / is_binary
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Is Binary"
      +}
    • addedOutput schema / properties / mime
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Mime"
      +}
    • addedOutput schema / properties / size
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Size"
      +}
    • addedOutput schema / properties / total_lines
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Total Lines"
      +}
  4. Addedv0.4.5
  5. Removedv0.4.1
  6. First observedv0.4.1

TDQS

A5/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 behavioral burden, and it does so thoroughly. It discloses the caching side effect ('Reading also caches the file so grep, search, and batch_read can see it'), the content_hash/known_hash protocol, the partial file_hash behavior, the coverage_token mechanism, and the binary-file metadata fallback.

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 lengthy but every paragraph earns its place given the tool's complex caching and hashing behavior. It is front-loaded with the core purpose, then progresses logically from hash protocol to ranged reads, outlines, and output flags, with no filler or repetition.

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?

The tool has seven parameters, no annotations, and no output schema, so the description must explain behavior and return values on its own. It covers the full content_hash lifecycle, unchanged/diff responses, partial hashes, coverage tokens, outline format, summary truncation, and binary metadata, leaving no material gap for an agent to call it 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 the schema already has 100% description coverage, the tool description adds substantial meaning beyond the schema. It explains how known_hash redeems content, why partial file_hash cannot be redeemed, how coverage_token extends ranged reads, what outline returns, and the max_size summarization threshold — all semantics an agent would not infer from parameter names alone.

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 specific verb and resource: 'Read a file, returning as few tokens as possible.' It also differentiates itself from siblings by explicitly directing multi-file reads to batch_read and images to read_image, so an agent can distinguish it without inspecting other schemas.

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?

The description explicitly states when alternatives should be used: 'For 2+ files, use batch_read' and 'for images use read_image.' It also advises outline=true as the cheap first read for large or unfamiliar files, and offset/limit for exact line ranges, giving clear contextual guidance and exclusions.

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