Skip to main content
Glama

read_source

Read-onlyIdempotent

Reads numbered code lines from a graph file or definition when facts are not enough, including for repositories on another machine; supports line ranges and pagination.

Instructions

Reads the text of one source file of the graph, or of one definition in it, and returns the lines numbered. Use it when the facts are not enough and the code itself is needed, above all when the repository is on another machine. target is a file path or module ID, a name (total), or <file>::Name when several files define the name; for a name the answer is that definition, from its line to the next definition. first and last are line numbers of the file. One call returns at most 400 lines and says how many are left and where to go on; a very long line is cut and says its length. It reads source files of the graph only: any other path is answered with an error. To find a name first use find_definitions; to find a text use search_source. A name the graph does not hold is answered with an error line, with suggestions when similar names exist.

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": {
      "target": "<target>"
    },
    "name": "read_source"
  }
}

Input Schema

NameRequiredDescriptionDefault
lastNoLast line to return (default: the end of the file or of the definition).
firstNoFirst line to return (default: the first line of the file or of the definition).
targetYesFile path or module ID, a name, or <file>::Name.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.15.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive, and the description adds substantial behavior on top: a hard 400-line cap with a report of how many lines remain and where to continue, truncation of very long lines with their length, and rejection of any path outside the graph. It also discloses error behavior for unknown names, including suggestions for near matches — none of which the annotations convey.

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 primary usage trigger, then moving to parameter mechanics and limits. The sentences are dense and nearly all earn their place; the parenthetical disambiguation and error-handling clauses add length but also value.

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?

For a read tool with no output schema, the description covers what an agent needs: input forms, default range behavior, output size limits and continuation, truncation behavior, and failure modes. Nothing material about calling it correctly 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 baseline would be 3, but the description adds real semantics: `target` may be a path, module ID, bare name, or `<file>::Name`, and for a bare name the result spans from that definition to the next one. It also clarifies that `first`/`last` are file line numbers. Only the interaction between an explicit range and a name-scoped target is left slightly implicit.

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 ('Reads the text of one source file of the graph, or of one definition in it') and even the return shape ('lines numbered'). It distinguishes itself from `search_source` and `find_definitions` by name, so an agent can tell the three apart without opening schemas.

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?

Gives an explicit trigger ('when the facts are not enough and the code itself is needed, above all when the repository is on another machine') and routes to named alternatives: `find_definitions` to locate a name, `search_source` to find text. It stops short of stating when *not* to use it (e.g. whole-repository reads), but the routing guidance is concrete.

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