Skip to main content
Glama

read

Fetches file contents with line numbers and encoding detection. Use offset/limit to retrieve specific line ranges; images are returned as base64.

Instructions

Reads a file and returns its contents with line numbers. Encoding-aware: auto-detects file encoding (UTF-8, EUC-KR, Shift-JIS, etc.). Image files (PNG, JPG, GIF, BMP, WebP, TIFF, ICO) are returned as ImageContent (base64). SVG files are returned as text. Supports offset/limit for reading specific line ranges. Text defaults to 400 lines and 32768 characters; use offset/limit to continue. Every text result ends with total line count, truncation state, and next_offset when more is available. Negative offset reads from end (e.g. offset=-5 reads last 5 lines). Offset accepts integer, string range "100-200", or [start, end] array. Accepts "path" as alias for "file_path". Relative paths use the configured workspace, MCP client root, or server CWD in that order.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allNoRemove the default line limit. The max_output_chars safety budget still applies. Default: false
pathNoCompatibility alias for file_path; prefer file_path
limitNoMaximum lines to return. Default: 400. Set 0 or all=true to remove the line limit; the character budget still applies
offsetNoLine offset. Integer (1-based, negative=from end), string range 'start-end', or [start,end] array. Default: 1
end_lineNoInclusive end line used with start_line
file_pathNoAbsolute or workspace-relative path to the file to read
start_lineNoCompatibility alias for offset; prefer offset
include_hashNoInclude SHA-256 for optimistic edit concurrency. Default: true
max_line_charsNoMaximum characters returned from one line. Default: 4000, Max: 32768
max_output_charsNoMaximum returned text characters. Default: 32768, Max: 131072

Schema Changelog

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

  1. Changed13 schema fields changedv0.9.5
    • addedInput schema / properties / all
      Added value: +{
      +  "description": "Remove the default line limit. The max_output_chars safety budget still applies. Default: false",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / end_line / description
      Previous value: -"End line number (1-based, inclusive). Sets limit = end_line - start_line + 1 when used with start_line"New value: +"Inclusive end line used with start_line"
    • addedInput schema / properties / end_line / type
      Added value: +[
      +  "null",
      +  "integer"
      +]
    • changedInput schema / properties / file_path / description
      Previous value: -"Absolute or relative path to the file to read"New value: +"Absolute or workspace-relative path to the file to read"
    • addedInput schema / properties / include_hash
      Added value: +{
      +  "description": "Include SHA-256 for optimistic edit concurrency. Default: true",
      +  "type": [
      +    "null",
      +    "boolean"
      +  ]
      +}
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum number of lines to read. Default: 0 (all)"New value: +"Maximum lines to return. Default: 400. Set 0 or all=true to remove the line limit; the character budget still applies"
    • addedInput schema / properties / limit / type
      Added value: +[
      +  "null",
      +  "integer"
      +]
    • addedInput schema / properties / max_line_chars
      Added value: +{
      +  "description": "Maximum characters returned from one line. Default: 4000, Max: 32768",
      +  "type": "integer"
      +}
    • addedInput schema / properties / max_output_chars
      Added value: +{
      +  "description": "Maximum returned text characters. Default: 32768, Max: 131072",
      +  "type": "integer"
      +}
    • changedInput schema / properties / offset / description
      Previous value: -"Line offset. Integer (1-based, negative=from end), string range 'start-end', or [start,end] array. Default: 0 (all)"New value: +"Line offset. Integer (1-based, negative=from end), string range 'start-end', or [start,end] array. Default: 1"
    • changedInput schema / properties / path / description
      Previous value: -"Alias for file_path"New value: +"Compatibility alias for file_path; prefer file_path"
    • changedInput schema / properties / start_line / description
      Previous value: -"Alias for offset (1-based line number to start reading from)"New value: +"Compatibility alias for offset; prefer offset"
    • addedInput schema / properties / start_line / type
      Added value: +[
      +  "null",
      +  "integer"
      +]
  2. Addedv0.8.7
  3. Removed
  4. Changed3 schema fields changedv0.7.12
    • changedInput schema / properties / offset / description
      Previous value: -"Line number to start reading from (1-based). Negative = from end (e.g. -5 = last 5 lines). Default: 1"New value: +"Line offset. Integer (1-based, negative=from end), string range 'start-end', or [start,end] array. Default: 0 (all)"
    • removedInput schema / properties / offset / type
      Removed value: -"integer"
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": false,
      -  "properties": {
      -    "content": {
      -      "type": "string"
      -    },
      -    "encoding": {
      -      "type": "string"
      -    },
      -    "hash": {
      -      "type": "string"
      -    },
      -    "total_lines": {
      -      "type": "integer"
      -    }
      -  },
      -  "required": [
      -    "content",
      -    "encoding",
      -    "total_lines"
      -  ],
      -  "type": "object"
      -}New value: +null
  5. First observedv0.4.2

TDQS

A4.4/5.0
Behavior5/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It covers encoding detection, binary-image base64 output, SVG as text, default text limits, truncation reporting, negative-offset semantics, path resolution, and concurrency hash inclusion. This is unusually transparent for a tool with no annotations.

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 front-loaded with the core purpose, and nearly every sentence adds distinct behavioral detail for a complex 10-parameter tool. Some information, such as the path alias and default limits, overlaps with schema fields, but the density is justified because there is no other documentation.

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?

With no output schema, the description explains the return shape concretely: line numbers, base64 ImageContent for images, SVG as text, and text results annotated with total line count, truncation state, and next_offset. Combined with the schema's full parameter descriptions, this gives an agent everything needed to correctly invoke and use the function.

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?

The input schema already documents all parameters at 100% coverage, but the description adds meaning through examples and combination rules, such as offset=-5, offset/limit continuation, and the explicit interpretation of 'all' and max_output_chars. It does not simply repeat the schema word-for-word, though some redundancy exists with the offset and alias 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 opens with a specific verb and resource: 'Reads a file and returns its contents with line numbers.' It also distinguishes itself from siblings by emphasizing single-file reads, image/SVG handling, and encoding detection, so an agent can differentiate it from multiread, edit, and other siblings without inspecting schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives rich operational context, such as using offset/limit to continue and negative offsets to read from the end, and it explains parameter aliases. However, it never explicitly says when to choose this tool over alternatives like multiread or grep, and there is no exclusion or routing guidance. Usage is implied rather than directly stated.

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/knewstimek/agent-tool'

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