Skip to main content
Glama

Read

read

Retrieve file content with token-efficient caching: unchanged files return a hash confirmation, changed files return unified diffs, and large files provide outlines or line ranges.

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.

A file larger than max_size returns a map instead of its text: the outline below, or for a file with no definitions its first and last lines under // L<a>-<b> anchors, flagged truncated with total_lines. Use offset/limit to read the exact lines it names. A read that returns only part of a file — a line range, or a map — 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 map. A binary file returns metadata instead of content; for images use read_image.

Input 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 a map of the file is returned instead of its text; read exact lines 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. Changed1 schema field changedv0.7.0
    • changedInput schema / properties / max_size / description
      Previous value: -"Byte threshold above which the file is semantically\nsummarized; recover exact lines afterward with `offset`/`limit`."New value: +"Byte threshold above which a map of the file is returned\ninstead of its text; read exact lines with `offset`/`limit`."
  2. 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
  3. 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"
      -}
  4. 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"
      +}
  5. Addedv0.4.5
  6. Removedv0.4.1
  7. First observedv0.4.1

TDQS

A4.9/5.0
Behavior5/5

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

With no annotations, the description carries the full behavioral burden and does so thoroughly: it explains token-saving behavior, caching side effects, `content_hash` workflows, partial-read hash semantics, truncation/map behavior, and binary-file handling. It does not contradict any annotation.

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 opening sentence front-loads the core action and the first sibling alternative. The remaining paragraphs are dense but purposeful, with each section explaining a distinct read mode or hash behavior rather than repeating schema text.

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 description is complete for a seven-parameter read tool with no annotations and no output schema. It explains the important return-value variants and the token/hash workflows an agent needs in order to call the tool correctly.

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 coverage is 100%, so the schema already defines all seven parameters. The description still adds meaningful cross-parameter semantics for `known_hash`, `coverage_token`, `offset`/`limit`, `outline`, and `max_size`, though it does not add much beyond the schema for parameters such as `line_numbers`.

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?

States a specific verb and resource: read a file, with the explicit goal of returning few tokens. It also distinguishes the tool from `batch_read` for multiple files and `read_image` for images, so an agent can select it without opening sibling 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?

Gives explicit routing guidance: use `batch_read` for 2+ files and `read_image` for images. It also explains when to use `outline=true`, `offset`/`limit`, and `known_hash`, including the conditions under which each produces cheaper or partial reads.

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