get_source
[analysis]
Read source declarations for an exact opaque symbolKey, including partial declarations and bounded context.
Available in Glider 13.0.0. Check that the installed server advertises get_source.
Before you use this tool
Source can be incomplete. Guarded declaration edits require sourceComplete=true, contextLines=0, bodyOnly=false, and equal declarationSpan/contentSpan. For replace_member, also compare get_symbol_info.replacementSpans. A shared-field variable is not a complete field declaration.
Try it locally in the Glider playground
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| symbolKey | string | Yes | Exact opaque key from find_code or another symbol tool. Pass it unchanged; names are unsupported. |
| filePath | string | No | Optional declaration file under the loaded root. Selects declarations of this key before paging. |
| skip | number | No | Declarations to skip after file selection. Default: 0 |
| take | number | No | Maximum declarations in this page. Default: 10 |
| contextLines | number | No | Extra lines before and after each declaration, from 0 to 20. Default: 0 |
| maxLines | number | No | Maximum lines per declaration window. 0 removes this bound; response limits still apply. Default: 200 |
| maxChars | number | No | Maximum UTF-16 characters per declaration window. 0 removes this bound; response limits still apply. Default: 20000 |
| bodyOnly | boolean | No | Select a method, constructor, or accessor body. A declaration without a body returns its declaration. Requires contextLines=0; other symbol kinds are invalid. Default: false |
| pathStyle | string | No | absolute or relative to solutionRoot. Default: "absolute" |
| responseDetail | string | No | compact returns results and actionable state. full adds diagnostic metadata under responseDiagnostics. Default: "compact" |
Examples
Replace sample paths and symbol keys with values from your workspace.
Read the selected declaration
{
"symbolKey": "<symbol key from find_code>"
}Full MCP request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_source",
"arguments": {
"symbolKey": "<symbol key from find_code>"
}
}
}{
"success": true,
"symbolKey": "...",
"fullName": "Acme.Orders.OrderService.Total()",
"kind": "Method",
"declarationCount": 1,
"selectedDeclarationCount": 1,
"paging": {
"total": 1
},
"declarations": [
{
"declarationIndex": 0,
"filePath": "/path/to/OrderService.cs",
"declarationKind": "MethodDeclaration",
"declarationSpan": {
"startLine": 3,
"startColumn": 5,
"endLine": 3,
"endColumn": 30,
"spanStart": 40,
"spanLength": 25
},
"selectedSpan": {
"startLine": 3,
"startColumn": 5,
"endLine": 3,
"endColumn": 30,
"spanStart": 40,
"spanLength": 25
},
"contentSpan": {
"startLine": 3,
"startColumn": 5,
"endLine": 3,
"endColumn": 30,
"spanStart": 40,
"spanLength": 25
},
"bodyOnly": false,
"contextLines": 0,
"lineCount": 1,
"truncated": false,
"truncationReason": null,
"source": "public int Total() => 42;",
"sourceComplete": true
}
]
}Read one partial declaration with context
{
"symbolKey": "<type key from find_code>",
"filePath": "/path/to/OrderService.cs",
"contextLines": 3
}Full MCP request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_source",
"arguments": {
"symbolKey": "<type key from find_code>",
"filePath": "/path/to/OrderService.cs",
"contextLines": 3
}
}
}Read a method body
{
"symbolKey": "<method key from find_code>",
"bodyOnly": true,
"maxLines": 80
}Full MCP request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_source",
"arguments": {
"symbolKey": "<method key from find_code>",
"bodyOnly": true,
"maxLines": 80
}
}
}Response Notes
Returns declarationCount, selectedDeclarationCount, paging, and declarations. File selection precedes declaration paging. Follow paging.nextSkip for additional parts. Partial methods and properties include definition and implementation parts. Each part reports declarationIndex, filePath, declarationKind, declarationSpan, selectedSpan, contentSpan, bodyOnly, contextLines, lineCount, truncated, truncationReason, source, and sourceComplete. source preserves exact whitespace and terminators. sourceComplete becomes false after a line, character, or response-budget cut. declarationSpan identifies the declaration; selectedSpan identifies the requested declaration or body; contentSpan identifies returned text with context and truncation. Spans use zero-based UTF-16 spanStart/spanLength and one-based startLine/startColumn/endLine/endColumn with exclusive ends. A single-variable field returns its field declaration. A shared-field variable returns only its VariableDeclarator. Get replacementSpans from get_symbol_info before replace_member. Canonical root checks precede pagination. An external symbol requires view_external_definition. A source symbol with no declaration returns source_unavailable. Rediscover an unresolved key in the intended workspace. Results use top-level fields with success. Compact is the default; full adds responseDiagnostics. Both modes retain errors, coverage, partial state, and recovery advice.
For a failed symbol-key request, success=false includes errorCode, parameter, error, and suggestions in compact, full, and batch operation results. Batch keeps a bounded summary outside the requested detail budget. If the hard server limit omits details, failureDetailsOmitted or writeStateOmitted identifies the omission. errorCode is invalid_symbol_key, symbol_not_found, ambiguous_symbol_key, wrong_symbol_kind, source_unavailable, unsupported_symbol, or invalid_arguments. Follow the suggestions for the specific failure. Correct the named selector for invalid_arguments. For symbol_not_found, repeat discovery in the selected workspace and pass a returned key unchanged. An absent identity does not prove that a key is stale.