Skip to main content
Glama

Read File

read
Read-only

Retrieve text file contents from the local filesystem, with options to return only head, tail, or a specific line range. Supports batch processing of multiple files in one call.

Instructions

Read one or more text files and return content. Partial reads: head (first N lines), tail (last N lines), startLine/endLine (line range). Batch mode: pass paths[] instead of path; line params are shared across all files. head, tail, and startLine/endLine are mutually exclusive — use exactly one.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
headNoReturn first N lines
pathNoSingle file path; mutually exclusive with paths
tailNoReturn last N lines
pathsNoArray of file paths for batch mode (max 1000); mutually exclusive with path
endLineNoEnd line (1-indexed)
startLineNoStart line (1-indexed)
includeHashNoInclude SHA-256 hash of the returned content in the response

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.4.1
    • addedInput schema / $schema
      Added value: +"https://json-schema.org/draft/2020-12/schema"
  2. 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
  3. 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"
      +]
  4. Addedv1.15.3
  5. Removedv1.15.0
  6. First observed

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, so the agent knows this is a safe read operation. The description adds key behavioral constraints: mutual exclusivity of line parameters, shared line params across batch files, and a limit of 1000 paths. It also implies content is returned but does not detail format, which is a minor gap.

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 compact, front-loads the core function, and clearly bundles related partial-read modes. It uses bullet-like lists and short sentences, with no fluff. Each clause serves a purpose, making it easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (7 params, partial reads, batch mode) and no output schema, the description covers the essential operation modes and constraints. It explains when to use batch, mutual exclusivity, and limits like max 1000 paths (though max limits are in schema, not description). It doesn't detail return format, but that is a minor gap given the read nature.

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 all parameters are documented, but the description adds crucial semantics about mutual exclusivity and batch behavior not fully captured in the schema. It clarifies how head, tail, and startLine/endLine are alternatives and how paths[] works with line params, going beyond the schema's static 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?

The description clearly states the tool reads one or more text files and returns content. It explicitly covers partial reads (head, tail, startLine/endLine) and batch mode via paths[]. This distinguishes it from siblings like find_files or search_text, which are for locating/searching rather than reading content.

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 that head, tail, and startLine/endLine are mutually exclusive and instructs to use exactly one. It also clearly explains batch mode when to pass paths[] instead of path. This provides explicit when-to-use guidance and exclusion of alternatives.

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