gograph_source
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
| Name | Required | Description | Default |
|---|---|---|---|
| root | No | Absolute path of your checkout or worktree (alias cwd). | |
| lines | No | 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 | |
| symbol | Yes | 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 | |
| intention | No | Rationale; required with an active session. | |
| session_id | No | Session from session_create; omit for none. |