Skip to main content
Glama

gograph_source

Read-onlyIdempotent

Retrieve verbatim Go source for a named function, type, or file line range without reading the whole file. Returns raw code with file paths and line numbers for targeted implementation review.

Instructions

Retrieve verbatim Go source for a named function, method, struct, interface, type, variable, or constant, including complete bodies or declarations. Source reads are confined to regular .go files beneath the analyzed repository and reject symlink path components. WHEN TO USE: When you need a specific implementation or declaration in full without loading a large file — a targeted alternative to reading the whole file. NOT TO USE: For call hierarchy information (use gograph_callers/gograph_callees); for AST metadata without the full source (use gograph_node). RETURNS: Raw Go source blocks with file paths and line numbers. The text carries the source or a named refusal: absent symbol, ambiguity with candidates, unsafe/unreadable source, invalid indexed range, or source exceeding 65536 bytes (with its size). With lines (START-END, file line numbers) it returns only that part of the declaration, so a region of a body over the budget can be read; symbol may then also be an indexed .go file path (e.g. 'internal/app/manager.go') to read any region of that file, including its import block.

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": {
      "symbol": "<symbol>"
    },
    "name": "gograph_source"
  }
}

Input Schema

NameRequiredDescriptionDefault
rootNoAbsolute path of your checkout or worktree (alias cwd).
linesNoOptional file line range START-END (1-based, inclusive). Limits the answer to those lines of the declaration, or of the file when symbol is a .go path
symbolYesThe name of the symbol to retrieve source for (supports short name 'ValidateToken', dot-notation 'graph.Graph', or fully-qualified ID); with lines, also an indexed .go file path
intentionNoRationale; required with an active session.
session_idNoSession from session_create; omit for none.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.7.26
    • addedInput schema / properties / lines
      Added value: +{
      +  "description": "Optional file line range START-END (1-based, inclusive). Limits the answer to those lines of the declaration, or of the file when symbol is a .go path",
      +  "type": "string"
      +}
    • changedInput schema / properties / symbol / description
      Previous value: -"The name of the symbol to retrieve source for (supports short name 'ValidateToken', dot-notation 'graph.Graph', or fully-qualified ID)"New value: +"The name of the symbol to retrieve source for (supports short name 'ValidateToken', dot-notation 'graph.Graph', or fully-qualified ID); with lines, also an indexed .go file path"
  2. Changed3 schema fields changedv1.7.21
    • changedInput schema / properties / intention / description
      Previous value: -"Technical rationale, required for analytical calls selecting an active session."New value: +"Rationale; required with an active session."
    • changedInput schema / properties / root / description
      Previous value: -"Absolute path of the checkout you are working in (your cwd or git worktree). Must be this server's repository or one of its git worktrees; the answer then comes from that checkout's own graph. A path elsewhere is refused. Alias: cwd. Omit only when the configured checkout is the one you mean."New value: +"Absolute path of your checkout or worktree (alias cwd)."
    • changedInput schema / properties / session_id / description
      Previous value: -"Caller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session."New value: +"Session from session_create; omit for none."
  3. Changed3 schema fields changedv1.7.18
    • addedInput schema / properties / intention
      Added value: +{
      +  "description": "Technical rationale, required for analytical calls selecting an active session.",
      +  "type": "string"
      +}
    • addedInput schema / properties / root
      Added value: +{
      +  "description": "Absolute path of the checkout you are working in (your cwd or git worktree). Must be this server's repository or one of its git worktrees; the answer then comes from that checkout's own graph. A path elsewhere is refused. Alias: cwd. Omit only when the configured checkout is the one you mean.",
      +  "type": "string"
      +}
    • addedInput schema / properties / session_id
      Added value: +{
      +  "description": "Caller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session.",
      +  "type": "string"
      +}
  4. Changed1 schema field changed
    • changedInput schema / properties / symbol / description
      Previous value: -"The name of the symbol (e.g., 'ValidateToken' or 'AuthService')"New value: +"The name of the symbol to retrieve source for (supports short name 'ValidateToken', dot-notation 'graph.Graph', or fully-qualified ID)"
  5. First observedv1.0.0

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), yet the description still adds substantive behavior: reads are confined to regular .go files under the analyzed repo, symlink path components are rejected, and there is a 65536-byte ceiling. It also enumerates the named refusal modes (absent symbol, ambiguity with candidates, unsafe/unreadable source, invalid range, oversize), which is exactly the kind of failure context annotations cannot convey. It stops short of describing ordering or formatting nuances, but the behavioral surface is well covered.

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 purpose, then cleanly sectioned as WHEN TO USE / NOT TO USE / RETURNS, so an agent can scan to the relevant block. The final sentence is long and packs the lines/symbol-file-path interplay densely, but no sentence is pure filler for a tool of this complexity.

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 carries the return-value burden and does: raw source blocks with file paths and line numbers, or a named refusal with the reason. Combined with the size budget, the lines escape hatch, and the sibling routing, an agent has everything needed to call this 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 is 3; the description earns more by explaining an interaction the schema only gestures at: with `lines` (START-END file line numbers) only that region is returned, which lets an agent read part of an over-budget body, and `symbol` then doubles as an indexed .go path to read any file region including its import block. That is genuine meaning beyond the field 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?

Opens with a specific verb+resource ('Retrieve verbatim Go source') and enumerates exactly which symbol kinds qualify (function, method, struct, interface, type, variable, constant) including bodies or declarations. It also names the siblings it is not (gograph_callers/gograph_callees, gograph_node), so an agent can place it without opening another schema.

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?

Explicit WHEN TO USE section frames it as a targeted alternative to reading a whole file, and NOT TO USE routes call-hierarchy questions to gograph_callers/gograph_callees and AST-metadata-only needs to gograph_node. The conditions that select each alternative are stated, not implied.

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