get_method_source
[analysis]
Gets source code for a method (bounded by max lines).
Try it locally in the Glider playground
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| methodName | string | No | Method name. Provide this or symbolKey. |
| symbolKey | string | No | A key returned by search_symbols or resolve_symbol. Pass it unchanged. Provide this or methodName. |
| containingTypeName | string | No | Optional containing type name filter. |
| projectName | string | No | Optional project name filter. |
| maxLines | number | No | Max lines to return. Use 0 for unlimited. Default is 120. Default: 120 |
| bodyOnly | boolean | No | If true, return only the method body (no signature). Default is false. Default: false |
| pathStyle | string | No | Path style: 'absolute' (default) or 'relative' (to solution root). 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.
Get method source
Arguments
{
"methodName": "GetUserById",
"containingTypeName": "UserService"
}Full MCP request
Full MCP request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_method_source",
"arguments": {
"methodName": "GetUserById",
"containingTypeName": "UserService"
}
}
}Illustrative response
{
"success": true,
"methodName": "GetUserById",
"containingType": "UserService",
"filePath": "/path/to/UserService.cs",
"startLine": 50,
"endLine": 80,
"lineCount": 31,
"truncated": false,
"source": "..."
}Response Notes
Returns workspace source for a method, possibly truncated. If a key does not resolve, discover the method again with search_symbols or resolve_symbol. A resolved method can still lack workspace source. When Glider identifies an external definition, the response provides an assembly hint and a view_external_definition call. Results use top-level fields with success. Compact is the default; full adds responseDiagnostics. Both modes retain errors, coverage, partial state, and recovery advice.