Skip to main content
Glama

get_source

Read-onlyIdempotent

Read the exact bounded source excerpt for a loaded design object, including upstream origins, without modifying files.

Instructions

Read the bounded source excerpt that produced an object (for example, an SV FF instance maps to its always_ff block; a netlist cell maps to its instantiation line). Use when exact source text is needed; use get_intent for typedef/enum/parameter semantics. When the response lists origins (e.g. Yosys src attributes), call again with origin=N to read that RTL. Returns object, file, start/end range, text, and truncation status without modifying files; missing paths and source ranges return structured errors.

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": "get_source"
  }
}

Input Schema

NameRequiredDescriptionDefault
bitNoBus bit index, separate from the literal name; omit for the whole object.
pathYesExact hierarchical path to a loaded design object.
originNoIndex into the object's `origins` list to read an upstream source (e.g. the RTL behind a Yosys netlist cell) instead of its declaration.
context_linesNoExtra lines before and after the source range; clamped to 0..20.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.2.0
    • addedInput schema / properties / bit
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Bus bit index, separate from the literal name; omit for the whole object.",
      +  "title": "Bit"
      +}
    • addedInput schema / properties / path / items
      Added value: +{
      +  "type": "string"
      +}
    • changedInput schema / properties / path / type
      Previous value: -"string"New value: +"array"
  2. Changed1 schema field changedv0.1.25
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "result": {
      +      "additionalProperties": true,
      +      "title": "Result",
      +      "type": "object"
      +    }
      +  },
      +  "required": [
      +    "result"
      +  ],
      +  "title": "get_sourceOutput",
      +  "type": "object"
      +}
  3. Changed2 schema fields changed
    • addedInput schema / properties / origin
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Index into the object's `origins` list to read an upstream source (e.g. the RTL behind a Yosys netlist cell) instead of its declaration.",
      +  "title": "Origin"
      +}
    • changedInput schema / properties / path / description
      Previous value: -"Exact hierarchical path to an object from a SystemVerilog load."New value: +"Exact hierarchical path to a loaded design object."
  4. Changed2 schema fields changedv0.1.9
    • addedInput schema / properties / context_lines / description
      Added value: +"Extra lines before and after the source range; clamped to 0..20."
    • addedInput schema / properties / path / description
      Added value: +"Exact hierarchical path to an object from a SystemVerilog load."
  5. First observedv0.1.8

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare read-only, idempotent, non-destructive, closed-world behavior, so the description's re-statement of 'without modifying files' adds little. It does add genuinely new behavior: truncation status in the response, structured errors for missing paths/ranges, and the origins recursion pattern for reading upstream RTL. It does not discuss size limits beyond truncation or cost of repeated calls.

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 purpose, then guidance, then the origins escalation, then the return/error contract; every sentence carries information. It is denser than strictly necessary — the file/range/text enumeration in the last sentence is largely covered by the output schema.

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 four-parameter read tool with full schema coverage, annotations, and an output schema, the description covers purpose, alternative tool, escalation path, error behavior, and truncation. An agent has everything needed to call it correctly and interpret failures.

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 would be 3. The description goes beyond it by explaining the workflow around `origin` — the response lists `origins`, and origin=N reads that upstream source instead of the declaration — which makes the parameter's purpose concrete rather than just an index. `bit` and `context_lines` are left entirely to the schema.

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 the bounded source excerpt that produced an object' — and anchors it with two concrete examples (SV FF instance to its `always_ff` block, netlist cell to its instantiation line). It also explicitly separates itself from `get_intent`, so an agent can pick between them 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 Guidelines5/5

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

Gives an explicit trigger ('use when exact source text is needed'), an explicit alternative for a different need ('use get_intent for typedef/enum/parameter semantics'), and a follow-up rule: when `origins` is returned, call again with origin=N to read upstream RTL. That is a complete use/avoid/escalate protocol.

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