analyze_complexity
Analyze Python code complexity per function in files or directories, returning metrics like cyclomatic, cognitive, nesting depth, length, and letter grades. Sort and filter by complexity.
Instructions
Analyze Python code complexity for a file or directory. Returns per-function metrics: cyclomatic complexity (McCabe), cognitive complexity, nesting depth, function length, and letter grades (A-F).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>"
},
"name": "analyze_complexity"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| top | No | Return only top N functions by complexity. 0 = all. | |
| path | Yes | File or directory path to analyze. | |
| sort_by | No | Sort metric (default: complexity). | complexity |
| threshold | No | Cyclomatic complexity threshold (default: 10). |