Browse documentation

get_method_source

[analysis]

Gets source code for a method (bounded by max lines).

Try it locally in the Glider playground

Parameters

NameTypeRequiredDescription
methodNamestringNoMethod name. Provide this or symbolKey.
symbolKeystringNoA key returned by search_symbols or resolve_symbol. Pass it unchanged. Provide this or methodName.
containingTypeNamestringNoOptional containing type name filter.
projectNamestringNoOptional project name filter.
maxLinesnumberNoMax lines to return. Use 0 for unlimited. Default is 120. Default: 120
bodyOnlybooleanNoIf true, return only the method body (no signature). Default is false. Default: false
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root). Default: "absolute"
responseDetailstringNocompact 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.