analyze_complexity

[architecture]

Analyzes code complexity metrics (cyclomatic complexity, LOC, method counts).

Try this tool in Playground.

Parameters

NameTypeRequiredDescription
typeNamestringNoOptional type name filter.
filePathstringNoOptional file path filter.
projectNamestringNoOptional project name filter.
minCyclomaticComplexitynumberNoOnly include methods with cyclomatic complexity >= this value. Default is 0.
sortBystringNoOptional sort: 'complexity', 'averageComplexity', 'linesOfCode', 'methodCount', 'name'.
sortOrderstringNoSort order: 'asc' (default) or 'desc'.
skipnumberNoPagination offset over returned types. Default is 0.
takenumberNoPagination size over returned types. Default is 50.
timeout_msnumberNoTimeout in milliseconds (5 minutes). Use 0 to disable. Default is 300000.

Examples

Analyze overall complexity

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "analyze_complexity",
    "arguments": {}
  }
}
Response
{
  "success": true,
  "data": {
    "summary": {
      "totalTypes": 12,
      "totalMethods": 84,
      "totalLinesOfCode": 3200,
      "averageComplexity": 3.1,
      "maxComplexity": 12,
      "highComplexityMethodCount": 4
    },
    "paging": {
      "skip": 0,
      "take": 50,
      "returned": 12,
      "total": 12
    },
    "types": [
      {
        "name": "SolutionManager",
        "fullName": "Glider.Services.SolutionManager",
        "kind": "Class",
        "filePath": "/path/to/SolutionManager.cs",
        "linesOfCode": 240,
        "methodCount": 8,
        "averageComplexity": 2.4,
        "methods": [
          {
            "name": "LoadSolutionAsync",
            "cyclomaticComplexity": 4,
            "linesOfCode": 32,
            "parameterCount": 1,
            "lineNumber": 58
          }
        ]
      }
    ]
  },
  "error": null
}

Show only high-complexity methods (>= 10)

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "analyze_complexity",
    "arguments": {
      "minCyclomaticComplexity": 10,
      "sortBy": "complexity",
      "sortOrder": "desc"
    }
  }
}
Response
{
  "success": true,
  "data": {
    "summary": {
      "totalTypes": 12,
      "totalMethods": 84,
      "totalLinesOfCode": 3200,
      "averageComplexity": 3.1,
      "maxComplexity": 12,
      "highComplexityMethodCount": 4
    },
    "paging": {
      "skip": 0,
      "take": 50,
      "returned": 12,
      "total": 12
    },
    "types": [
      {
        "name": "SolutionManager",
        "fullName": "Glider.Services.SolutionManager",
        "kind": "Class",
        "filePath": "/path/to/SolutionManager.cs",
        "linesOfCode": 240,
        "methodCount": 8,
        "averageComplexity": 2.4,
        "methods": [
          {
            "name": "LoadSolutionAsync",
            "cyclomaticComplexity": 4,
            "linesOfCode": 32,
            "parameterCount": 1,
            "lineNumber": 58
          }
        ]
      }
    ]
  },
  "error": null
}

Response Notes

Returns summary metrics and per-type complexity details (with paging)