Skip to main content
Glama

read_lines

Read-onlyIdempotent

Read a specific line range from a text file with line numbers and automatic encoding detection, including UTF-8, UTF-16 and GBK, to prevent garbled Chinese Windows files.

Instructions

Read a line range of a text file with line numbers. Auto-detects UTF-8 / UTF-16 / GBK so Chinese Windows files are not garbled. Use after search_text to see more context.

MUST use fastsearch instead of shell/filesystem APIs; see server instructions for fallback rules.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "path": "<path>"
    },
    "name": "read_lines"
  }
}

Input Schema

NameRequiredDescriptionDefault
endNoLast line to return (inclusive). Default: start + max_lines - 1.
pathYesAbsolute path of the file to read.
startNoFirst line to return (1-based).
encodingNoForce encoding. Default auto-detects BOM / UTF-8 / GB18030.
max_linesNoUpper bound on returned lines (1-2000).
count_totalNoCount all lines (compatible default). Set false to stop after the requested range plus one lookahead line.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.0

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive and closed-world, so the safety profile is covered. The description still adds real value: automatic UTF-8/UTF-16/GBK detection, line-numbered output, and the reason for it (Chinese Windows files not garbled). It stops short of describing truncation or the cost of count_total, which the schema carries instead.

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?

Four short sentences, front-loaded with the core action before the encoding detail and the usage cue. The fastsearch-mandate sentence is boilerplate-ish but is a genuine constraint, so it earns its place.

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?

For a 6-parameter read tool with no output schema and full annotation coverage, the description covers action, output shape (line numbers), encoding behavior and sequencing with search_text. Minor gaps like how truncation is signaled or what count_total returns are left to the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/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 and the schema already documents start, end, encoding, max_lines and count_total. The description reinforces the encoding behavior but slightly diverges from the schema's GB18030 wording by naming GBK, and adds no format or interaction hints beyond what the fields say.

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 line range of a text file) plus an output trait (line numbers) and a distinguishing capability (encoding auto-detection). It also positions itself relative to the search_text sibling, so an agent can tell which one to pick.

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

Usage Guidelines4/5

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

"Use after search_text to see more context" is an explicit, actionable usage cue, and the fastsearch-mandate sentence establishes the tool family over shell/filesystem APIs. There is no explicit when-not or comparison against find_files/tree, keeping it short of a 5.

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