Browse documentation

analyze_complexity

[architecture]

Analyzes cyclomatic complexity and size metrics. Select an exact member method or type with symbolKey, or use file and name filters.

Try it locally in the Glider playground

Parameters

NameTypeRequiredDescription
symbolKeystringNoExact source member method or type key from symbol discovery. Local functions are unsupported. Do not combine with typeName, filePath, or projectName.
typeNamestringNoOptional type name filter.
filePathstringNoOptional file path filter.
projectNamestringNoOptional project name filter.
minCyclomaticComplexitynumberNoOnly include methods with cyclomatic complexity >= this value. Default is 0. Default: 0
sortBystringNoOptional sort: 'complexity', 'averageComplexity', 'linesOfCode', 'methodCount', 'name'.
sortOrderstringNoSort order: 'asc' (default) or 'desc'. Default: "asc"
skipnumberNoPagination offset over returned types. Default is 0. Default: 0
takenumberNoPagination size over returned types. Default is 50. Default: 50
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.

Analyze overall complexity

Arguments
{}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "analyze_complexity",
    "arguments": {}
  }
}
Illustrative response
{
  "success": true,
  "summary": {
    "totalTypes": 1,
    "totalMethods": 2,
    "totalLinesOfCode": 80,
    "averageComplexity": 8,
    "maxComplexity": 12,
    "highComplexityMethodCount": 1
  },
  "paging": {
    "total": 1
  },
  "types": [
    {
      "name": "OrderService",
      "fullName": "Acme.Orders.OrderService",
      "kind": "Class",
      "filePath": "/workspace/Orders/OrderService.cs",
      "linesOfCode": 80,
      "methodCount": 2,
      "averageComplexity": 8,
      "methods": [
        {
          "name": "SubmitOrder",
          "cyclomaticComplexity": 4,
          "linesOfCode": 16,
          "parameterCount": 1,
          "lineNumber": 10,
          "filePath": "/workspace/Orders/OrderService.cs"
        },
        {
          "name": "ValidateOrder",
          "cyclomaticComplexity": 12,
          "linesOfCode": 32,
          "parameterCount": 1,
          "lineNumber": 30,
          "filePath": "/workspace/Orders/OrderService.cs"
        }
      ]
    }
  ]
}

Analyze one exact method with a key from symbol discovery

Arguments
{
  "symbolKey": "<method symbolKey returned by search_symbols or resolve_symbol>"
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "analyze_complexity",
    "arguments": {
      "symbolKey": "<method symbolKey returned by search_symbols or resolve_symbol>"
    }
  }
}
Illustrative response
{
  "success": true,
  "summary": {
    "totalTypes": 1,
    "totalMethods": 1,
    "totalLinesOfCode": 16,
    "averageComplexity": 4,
    "maxComplexity": 4,
    "highComplexityMethodCount": 0
  },
  "paging": {
    "total": 1
  },
  "types": [
    {
      "name": "OrderService",
      "fullName": "Acme.Orders.OrderService",
      "kind": "Class",
      "filePath": "/workspace/Orders/OrderService.cs",
      "linesOfCode": 16,
      "methodCount": 1,
      "averageComplexity": 4,
      "methods": [
        {
          "name": "SubmitOrder",
          "cyclomaticComplexity": 4,
          "linesOfCode": 16,
          "parameterCount": 1,
          "lineNumber": 10,
          "filePath": "/workspace/Orders/OrderService.cs"
        }
      ]
    }
  ]
}

Analyze a type across all partial declarations with a discovered key

Arguments
{
  "symbolKey": "<type symbolKey returned by search_symbols or resolve_symbol>"
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "analyze_complexity",
    "arguments": {
      "symbolKey": "<type symbolKey returned by search_symbols or resolve_symbol>"
    }
  }
}
Illustrative response
{
  "success": true,
  "summary": {
    "totalTypes": 1,
    "totalMethods": 2,
    "totalLinesOfCode": 80,
    "averageComplexity": 8,
    "maxComplexity": 12,
    "highComplexityMethodCount": 1
  },
  "paging": {
    "total": 1
  },
  "types": [
    {
      "name": "OrderService",
      "fullName": "Acme.Orders.OrderService",
      "kind": "Class",
      "filePath": "/workspace/Orders/OrderService.cs",
      "linesOfCode": 80,
      "methodCount": 2,
      "averageComplexity": 8,
      "methods": [
        {
          "name": "SubmitOrder",
          "cyclomaticComplexity": 4,
          "linesOfCode": 16,
          "parameterCount": 1,
          "lineNumber": 10,
          "filePath": "/workspace/Orders/OrderService.cs"
        },
        {
          "name": "ValidateOrder",
          "cyclomaticComplexity": 12,
          "linesOfCode": 32,
          "parameterCount": 1,
          "lineNumber": 30,
          "filePath": "/workspace/Orders/OrderService.cs"
        }
      ]
    }
  ]
}

Show only high-complexity methods (>= 10)

Arguments
{
  "minCyclomaticComplexity": 10,
  "sortBy": "complexity",
  "sortOrder": "desc"
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "analyze_complexity",
    "arguments": {
      "minCyclomaticComplexity": 10,
      "sortBy": "complexity",
      "sortOrder": "desc"
    }
  }
}
Illustrative response
{
  "success": true,
  "summary": {
    "totalTypes": 1,
    "totalMethods": 2,
    "totalLinesOfCode": 80,
    "averageComplexity": 8,
    "maxComplexity": 12,
    "highComplexityMethodCount": 1
  },
  "paging": {
    "total": 1
  },
  "types": [
    {
      "name": "OrderService",
      "fullName": "Acme.Orders.OrderService",
      "kind": "Class",
      "filePath": "/workspace/Orders/OrderService.cs",
      "linesOfCode": 80,
      "methodCount": 2,
      "averageComplexity": 8,
      "methods": [
        {
          "name": "ValidateOrder",
          "cyclomaticComplexity": 12,
          "linesOfCode": 32,
          "parameterCount": 1,
          "lineNumber": 30,
          "filePath": "/workspace/Orders/OrderService.cs"
        }
      ]
    }
  ]
}

Response Notes

Returns summary metrics and a page of types. A member method key selects one exact overload; all aggregates describe that method. Explicit accessor keys select one accessor body. Position discovery uses declaration keys for constructed generic and reduced extension methods. A type key combines its partial declarations and excludes nested types. Partial methods use their implementation once.

Primary constructor metrics cover the header, base arguments, and instance initializers. Other member bodies and bodyless accessors do not contribute. Each method includes its own filePath. The type filePath identifies the first declaration. Threshold filters affect method lists and type inclusion; aggregates retain the selected scope before filtering and paging.

Bodyless accessor keys, local functions, fields, properties, namespaces, metadata symbols, implicit symbols, and conflicting selectors return errors. Obtain keys from discovery; replace the example placeholders before calling. Results use top-level fields with success. Compact is the default; full adds responseDiagnostics. Both modes retain errors, coverage, partial state, and recovery advice.