Skip to main content
Glama

Read File

read
Read-onlyIdempotent

Retrieve file contents from one or up to 1,000 known paths, whole or as line slices; use stat for size or existence checks and search, find, or list to locate files.

Instructions

Read one file or up to 1000, whole or as a line slice. Use when you know the path. Do not use it to check size or existence; use stat instead. To locate content, use search_text, find_files, or list. Only whole reads return images and audio as media; other binary files fail with BINARY_FILE unless binary: true. Pick one slice (head, tail, or startLine/endLine); it applies to every batch file. Past the size limit: a single-path whole read returns its first 2000 lines (up to 256 KiB) with continuation args; a head or range is truncated; a batch file fails TOO_LARGE. UTF-16 text with a byte-order mark is returned decoded, with encoding set; past the size limit it fails TOO_LARGE in every mode. Non-UTF-8 text is returned with U+FFFD and lossy: true. A batch shares a 512 KiB budget: an overflowing file is skipped and later files still read. isError means every path failed. Returns text plus per-path results[]: an error, or linesRead, hasMoreLines, continuation args, modified, optional contentHash. Full reads add totalLines; a tail gets no continuation.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "read"
  }
}

Input Schema

NameRequiredDescriptionDefault
headNoFirst N lines. Not with tail or startLine/endLine.
pathNoSingle file path; mutually exclusive with paths
tailNoLast N lines. Not with head, startLine/endLine, or lineNumbers.
pathsNoArray of file paths for batch mode (max 1000); mutually exclusive with path
binaryNoReturn a non-image, non-audio binary file as a base64 resource. Whole reads only. Without it, such a file fails with BINARY_FILE.
endLineNoLast line, inclusive. Requires startLine.
startLineNoFirst line, 1-based. Without endLine, reads to the end.
includeHashNoInclude SHA-256 of the returned content (the slice for a partial read).
lineNumbersNoPrefix each line with its number and a tab. Not with tail. Leave the prefix out of edit text.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.22.0
    • changedInput schema / properties / paths / items / description
      Previous value: -"File or directory path inside an allowed workspace root."New value: +"File or directory path inside a root, absolute or relative to it."
  2. Changed7 schema fields changedv2.20.0
    • changedInput schema / properties / binary / description
      Previous value: -"Return a binary file that is not an image or audio whole, as a base64 embedded resource. Full reads only."New value: +"Return a non-image, non-audio binary file as a base64 resource. Whole reads only. Without it, such a file fails with BINARY_FILE."
    • changedInput schema / properties / endLine / description
      Previous value: -"End line (1-indexed); requires startLine"New value: +"Last line, inclusive. Requires startLine."
    • changedInput schema / properties / head / description
      Previous value: -"Return first N lines"New value: +"First N lines. Not with tail or startLine/endLine."
    • changedInput schema / properties / includeHash / description
      Previous value: -"Include SHA-256 of the returned content (the slice for head, tail or a line range)"New value: +"Include SHA-256 of the returned content (the slice for a partial read)."
    • changedInput schema / properties / lineNumbers / description
      Previous value: -"Prefix each line with its number and a tab, like cat -n. Not with tail. Leave the prefix out of edit text."New value: +"Prefix each line with its number and a tab. Not with tail. Leave the prefix out of edit text."
    • changedInput schema / properties / startLine / description
      Previous value: -"Start line (1-indexed)"New value: +"First line, 1-based. Without endLine, reads to the end."
    • changedInput schema / properties / tail / description
      Previous value: -"Return last N lines"New value: +"Last N lines. Not with head, startLine/endLine, or lineNumbers."
  3. Changed1 schema field changedv2.19.0
    • changedInput schema / properties / includeHash / description
      Previous value: -"Include SHA-256 hash of the returned content in the response"New value: +"Include SHA-256 of the returned content (the slice for head, tail or a line range)"
  4. Changed1 schema field changedv2.17.0
    • addedInput schema / properties / lineNumbers
      Added value: +{
      +  "default": false,
      +  "description": "Prefix each line with its number and a tab, like cat -n. Not with tail. Leave the prefix out of edit text.",
      +  "type": "boolean"
      +}
  5. Changed4 schema fields changedv2.9.1
    • removedInput schema / dependentRequired
      Removed value: -{
      -  "endLine": [
      -    "startLine"
      -  ]
      -}
    • removedInput schema / oneOf
      Removed value: -[
      -  {
      -    "required": [
      -      "path"
      -    ]
      -  },
      -  {
      -    "required": [
      -      "paths"
      -    ]
      -  }
      -]
    • addedInput schema / properties / binary
      Added value: +{
      +  "default": false,
      +  "description": "Return a binary file that is not an image or audio whole, as a base64 embedded resource. Full reads only.",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / endLine / description
      Previous value: -"End line (1-indexed)"New value: +"End line (1-indexed); requires startLine"
  6. Changed2 schema fields changedv2.8.1
    • changedInput schema / properties / endLine / maximum
      Previous value: -100000New value: +2147483647
    • changedInput schema / properties / startLine / maximum
      Previous value: -100000New value: +2147483647
  7. Changed1 schema field changedv2.4.1
    • addedInput schema / $schema
      Added value: +"https://json-schema.org/draft/2020-12/schema"
  8. Changed1 schema field changedv2.1.5
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": false,
      -  "properties": {
      -    "results": {
      -      "description": "Per-path results ordered to match the input paths",
      -      "items": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "error": {
      -            "additionalProperties": false,
      -            "description": "Error details; present on failure",
      -            "properties": {
      -              "code": {
      -                "type": "string"
      -              },
      -              "message": {
      -                "type": "string"
      -              },
      -              "path": {
      -                "type": "string"
      -              },
      -              "suggestion": {
      -                "type": "string"
      -              }
      -            },
      -            "required": [
      -              "code",
      -              "message"
      -            ],
      -            "type": "object"
      -          },
      -          "path": {
      -            "description": "Requested file path",
      -            "type": "string"
      -          },
      -          "value": {
      -            "additionalProperties": false,
      -            "description": "Read result; present on success",
      -            "properties": {
      -              "contentHash": {
      -                "description": "SHA-256 hex digest of the returned content (present when includeHash=true)",
      -                "pattern": "^[0-9a-f]{64}$",
      -                "type": "string"
      -              },
      -              "continuation": {
      -                "additionalProperties": false,
      -                "description": "Next-read arguments; present when content was truncated due to size limits",
      -                "properties": {
      -                  "args": {
      -                    "additionalProperties": false,
      -                    "description": "Ready-to-use arguments for the next call; pass verbatim",
      -                    "properties": {
      -                      "endLine": {
      -                        "exclusiveMinimum": 0,
      -                        "type": "integer"
      -                      },
      -                      "path": {
      -                        "type": "string"
      -                      },
      -                      "startLine": {
      -                        "exclusiveMinimum": 0,
      -                        "type": "integer"
      -                      }
      -                    },
      -                    "required": [
      -                      "path",
      -                      "startLine",
      -                      "endLine"
      -                    ],
      -                    "type": "object"
      -                  },
      -                  "hint": {
      -                    "description": "One-sentence description of the data still remaining to be read",
      -                    "type": "string"
      -                  },
      -                  "tool": {
      -                    "description": "Tool name to call for the next chunk",
      -                    "type": "string"
      -                  }
      -                },
      -                "required": [
      -                  "tool",
      -                  "args",
      -                  "hint"
      -                ],
      -                "type": "object"
      -              },
      -              "endLine": {
      -                "description": "End line",
      -                "exclusiveMinimum": 0,
      -                "type": "integer"
      -              },
      -              "hasMoreLines": {
      -                "description": "True when additional lines remain beyond what was returned",
      -                "type": "boolean"
      -              },
      -              "head": {
      -                "description": "Head lines requested",
      -                "exclusiveMinimum": 0,
      -                "type": "integer"
      -              },
      -              "kind": {
      -                "description": "Broad file kind: text, binary, image, audio, or pdf",
      -                "enum": [
      -                  "text",
      -                  "binary",
      -                  "image",
      -                  "audio",
      -                  "pdf"
      -                ],
      -                "type": "string"
      -              },
      -              "linesRead": {
      -                "description": "Number of lines returned in this response",
      -                "minimum": 0,
      -                "type": "integer"
      -              },
      -              "mimeType": {
      -                "description": "Detected MIME type (e.g. text/typescript)",
      -                "type": "string"
      -              },
      -              "resourceUri": {
      -                "description": "Resource URI for externalized content (present when file is stored in resource store)",
      -                "type": "string"
      -              },
      -              "startLine": {
      -                "description": "Start line",
      -                "exclusiveMinimum": 0,
      -                "type": "integer"
      -              },
      -              "tail": {
      -                "description": "Tail lines requested",
      -                "exclusiveMinimum": 0,
      -                "type": "integer"
      -              },
      -              "totalLines": {
      -                "description": "Total line count in the full file",
      -                "minimum": 0,
      -                "type": "integer"
      -              }
      -            },
      -            "type": "object"
      -          }
      -        },
      -        "required": [
      -          "path"
      -        ],
      -        "type": "object"
      -      },
      -      "type": "array"
      -    },
      -    "summary": {
      -      "additionalProperties": false,
      -      "properties": {
      -        "failed": {
      -          "minimum": 0,
      -          "type": "integer"
      -        },
      -        "succeeded": {
      -          "minimum": 0,
      -          "type": "integer"
      -        },
      -        "total": {
      -          "minimum": 0,
      -          "type": "integer"
      -        }
      -      },
      -      "required": [
      -        "total",
      -        "succeeded",
      -        "failed"
      -      ],
      -      "type": "object"
      -    }
      -  },
      -  "required": [
      -    "results",
      -    "summary"
      -  ],
      -  "type": "object"
      -}New value: +null
  9. Changed31 schema fields changedv2.0.0
    • removedInput schema / $schema
      Removed value: -"https://json-schema.org/draft/2020-12/schema"
    • addedInput schema / dependentRequired
      Added value: +{
      +  "endLine": [
      +    "startLine"
      +  ]
      +}
    • removedInput schema / description
      Removed value: -"Use one read mode only: 'head', 'tail', or 'startLine'/'endLine'."
    • addedInput schema / oneOf
      Added value: +[
      +  {
      +    "required": [
      +      "path"
      +    ]
      +  },
      +  {
      +    "required": [
      +      "paths"
      +    ]
      +  }
      +]
    • changedInput schema / properties / endLine / description
      Previous value: -"End line (1-based, inclusive). Defaults to last line when startLine is set."New value: +"End line (1-indexed)"
    • changedInput schema / properties / endLine / maximum
      Previous value: -9007199254740991New value: +100000
    • changedInput schema / properties / head / description
      Previous value: -"Read first N lines (preview)"New value: +"Return first N lines"
    • changedInput schema / properties / includeHash / description
      Previous value: -"Include SHA-256 hash of full file content"New value: +"Include SHA-256 hash of the returned content in the response"
    • changedInput schema / properties / path / description
      Previous value: -"Absolute path to file or directory."New value: +"Single file path; mutually exclusive with paths"
    • addedInput schema / properties / paths
      Added value: +{
      +  "description": "Array of file paths for batch mode (max 1000); mutually exclusive with path",
      +  "items": {
      +    "description": "File or directory path inside an allowed workspace root.",
      +    "maxLength": 4096,
      +    "minLength": 1,
      +    "type": "string"
      +  },
      +  "maxItems": 1000,
      +  "minItems": 1,
      +  "type": "array"
      +}
    • changedInput schema / properties / startLine / description
      Previous value: -"Start line (1-based, inclusive). Defaults to 1 when endLine is set."New value: +"Start line (1-indexed)"
    • changedInput schema / properties / startLine / maximum
      Previous value: -9007199254740991New value: +100000
    • changedInput schema / properties / tail / description
      Previous value: -"Read last N lines"New value: +"Return last N lines"
    • removedInput schema / required
      Removed value: -[
      -  "path"
      -]
    • removedOutput schema / $schema
      Removed value: -"https://json-schema.org/draft/2020-12/schema"
    • removedOutput schema / properties / content
      Removed value: -{
      -  "description": "Content",
      -  "type": "string"
      -}
    • removedOutput schema / properties / contentHash
      Removed value: -{
      -  "description": "SHA-256 of full file content",
      -  "pattern": "^[a-f0-9]{64}$",
      -  "type": "string"
      -}
    • removedOutput schema / properties / endLine
      Removed value: -{
      -  "description": "End line",
      -  "maximum": 9007199254740991,
      -  "minimum": 1,
      -  "type": "integer"
      -}
    • removedOutput schema / properties / hasMoreLines
      Removed value: -{
      -  "description": "More lines?",
      -  "type": "boolean"
      -}
    • removedOutput schema / properties / head
      Removed value: -{
      -  "description": "Head lines",
      -  "maximum": 9007199254740991,
      -  "minimum": 1,
      -  "type": "integer"
      -}
    • removedOutput schema / properties / linesRead
      Removed value: -{
      -  "description": "Lines read",
      -  "maximum": 9007199254740991,
      -  "minimum": 0,
      -  "type": "integer"
      -}
    • removedOutput schema / properties / ok
      Removed value: -{
      -  "const": true,
      -  "type": "boolean"
      -}
    • removedOutput schema / properties / path
      Removed value: -{
      -  "type": "string"
      -}
    • removedOutput schema / properties / resourceUri
      Removed value: -{
      -  "description": "Full content URI",
      -  "type": "string"
      -}
    • addedOutput schema / properties / results
      Added value: +{
      +  "description": "Per-path results ordered to match the input paths",
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "error": {
      +        "additionalProperties": false,
      +        "description": "Error details; present on failure",
      +        "properties": {
      +          "code": {
      +            "type": "string"
      +          },
      +          "message": {
      +            "type": "string"
      +          },
      +          "path": {
      +            "type": "string"
      +          },
      +          "suggestion": {
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "code",
      +          "message"
      +        ],
      +        "type": "object"
      +      },
      +      "path": {
      +        "description": "Requested file path",
      +        "type": "string"
      +      },
      +      "value": {
      +        "additionalProperties": false,
      +        "description": "Read result; present on success",
      +        "properties": {
      +          "contentHash": {
      +            "description": "SHA-256 hex digest of the returned content (present when includeHash=true)",
      +            "pattern": "^[0-9a-f]{64}$",
      +            "type": "string"
      +          },
      +          "continuation": {
      +            "additionalProperties": false,
      +            "description": "Next-read arguments; present when content was truncated due to size limits",
      +            "properties": {
      +              "args": {
      +                "additionalProperties": false,
      +                "description": "Ready-to-use arguments for the next call; pass verbatim",
      +                "properties": {
      +                  "endLine": {
      +                    "exclusiveMinimum": 0,
      +                    "type": "integer"
      +                  },
      +                  "path": {
      +                    "type": "string"
      +                  },
      +                  "startLine": {
      +                    "exclusiveMinimum": 0,
      +                    "type": "integer"
      +                  }
      +                },
      +                "required": [
      +                  "path",
      +                  "startLine",
      +                  "endLine"
      +                ],
      +                "type": "object"
      +              },
      +              "hint": {
      +                "description": "One-sentence description of the data still remaining to be read",
      +                "type": "string"
      +              },
      +              "tool": {
      +                "description": "Tool name to call for the next chunk",
      +                "type": "string"
      +              }
      +            },
      +            "required": [
      +              "tool",
      +              "args",
      +              "hint"
      +            ],
      +            "type": "object"
      +          },
      +          "endLine": {
      +            "description": "End line",
      +            "exclusiveMinimum": 0,
      +            "type": "integer"
      +          },
      +          "hasMoreLines": {
      +            "description": "True when additional lines remain beyond what was returned",
      +            "type": "boolean"
      +          },
      +          "head": {
      +            "description": "Head lines requested",
      +            "exclusiveMinimum": 0,
      +            "type": "integer"
      +          },
      +          "kind": {
      +            "description": "Broad file kind: text, binary, image, audio, or pdf",
      +            "enum": [
      +              "text",
      +              "binary",
      +              "image",
      +              "audio",
      +              "pdf"
      +            ],
      +            "type": "string"
      +          },
      +          "linesRead": {
      +            "description": "Number of lines returned in this response",
      +            "minimum": 0,
      +            "type": "integer"
      +          },
      +          "mimeType": {
      +            "description": "Detected MIME type (e.g. text/typescript)",
      +            "type": "string"
      +          },
      +          "resourceUri": {
      +            "description": "Resource URI for externalized content (present when file is stored in resource store)",
      +            "type": "string"
      +          },
      +          "startLine": {
      +            "description": "Start line",
      +            "exclusiveMinimum": 0,
      +            "type": "integer"
      +          },
      +          "tail": {
      +            "description": "Tail lines requested",
      +            "exclusiveMinimum": 0,
      +            "type": "integer"
      +          },
      +          "totalLines": {
      +            "description": "Total line count in the full file",
      +            "minimum": 0,
      +            "type": "integer"
      +          }
      +        },
      +        "type": "object"
      +      }
      +    },
      +    "required": [
      +      "path"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • removedOutput schema / properties / startLine
      Removed value: -{
      -  "description": "Start line",
      -  "maximum": 9007199254740991,
      -  "minimum": 1,
      -  "type": "integer"
      -}
    • addedOutput schema / properties / summary
      Added value: +{
      +  "additionalProperties": false,
      +  "properties": {
      +    "failed": {
      +      "minimum": 0,
      +      "type": "integer"
      +    },
      +    "succeeded": {
      +      "minimum": 0,
      +      "type": "integer"
      +    },
      +    "total": {
      +      "minimum": 0,
      +      "type": "integer"
      +    }
      +  },
      +  "required": [
      +    "total",
      +    "succeeded",
      +    "failed"
      +  ],
      +  "type": "object"
      +}
    • removedOutput schema / properties / tail
      Removed value: -{
      -  "description": "Tail lines",
      -  "maximum": 9007199254740991,
      -  "minimum": 1,
      -  "type": "integer"
      -}
    • removedOutput schema / properties / totalLines
      Removed value: -{
      -  "description": "Total lines",
      -  "maximum": 9007199254740991,
      -  "minimum": 0,
      -  "type": "integer"
      -}
    • removedOutput schema / properties / truncated
      Removed value: -{
      -  "description": "Truncated?",
      -  "type": "boolean"
      -}
    • changedOutput schema / required
      Previous value: -[
      -  "ok"
      -]New value: +[
      +  "results",
      +  "summary"
      +]
  10. Addedv1.15.3
  11. Removedv1.15.0
  12. First observed

TDQS

A4.4/5.0
Behavior3/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), so the bar is lower, but the description still adds real context: binary/TOO_LARGE failure modes, the 512 KiB batch budget with skip-and-continue semantics, UTF-16 decoding with encoding set, and lossy U+FFFD handling. It also defines isError semantics and the per-path results[] shape, which no output schema provides.

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?

Front-loaded with the core action and the routing rule before the edge cases, and nearly every sentence carries an operational fact. It is dense to the point of reading like a changelog in the back half, which slightly hurts scanning, but nothing is filler.

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?

Nine parameters, no output schema, and the description covers what's needed to call it correctly and interpret results: slice exclusivity, batch budgeting, truncation/continuation behavior, encoding caveats, and the results[] contract. Annotations supply the safety profile, so nothing material 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 coverage is 100%, so the baseline is 3, but the description adds cross-parameter meaning the schema can't: only whole reads return images/audio as media, exactly one slice mode must be chosen and it applies to every batch file, and head/range/tail behave differently past the size limit. That is genuine interaction semantics beyond per-field descriptions.

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 with scope baked in ('Read one file or up to 1000, whole or as a line slice'), and immediately tells the agent which sibling handles the adjacent jobs (stat, search_text, find_files, list). An agent can distinguish this from every listed sibling without opening a schema.

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?

Explicit when-to-use ('Use when you know the path'), explicit when-not ('Do not use it to check size or existence; use stat instead'), and named alternatives for the content-location case. This is the full when/when-not/alternatives triad.

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