AST Cyclomatic Complexity Calculator

AST Cyclomatic Complexity Calculator MCP Connector for Claude

A+

Measure code maintainability by calculating exact cyclomatic complexity using regex-based decision point counting.

3 tools Official Updated Oct 1, 2026 Official Vinkius Partner

The AST Cyclomatic Complexity Calculator provides a deterministic way to audit code maintainability. By scanning source code for specific control flow keywords and logical operators, it calculates the number of independent paths through each function. Use analyze_complexity to get a full breakdown of functions, identify_refactor_candidates to find high-risk functions exceeding the complexity threshold, or compare_complexity_impact to detect regressions between code versions.

complexitycyclomaticrefactoringmaintainabilitystatic-analysisjavascripttypescript

3 tools expose this connector's capabilities to your AI agent.

identify_refactor_candidates

Identify functions that need refactoring

analyze_complexity

Analyze the cyclomatic complexity of source code

compare_complexity_impact

Compare complexity between two versions of code

See how to talk to your AI agent using AST Cyclomatic Complexity Calculator.

Analyze this function for complexity: 'function test(a) { if (a) { return true; } else { return false; } }'

{ "functions": [{"functionName": "test", "complexity": 2, "lineNumber": 1}], "totalComplexity": 2 }

Identify refactor candidates in this code: 'function heavy(x) { if (x) { if (x) { if (x) { if (x) { if (x) { if (x) { if (x) { if (x) { if (x) { if (x) { return 1; } } } } } } } } } }'

{ "highComplexityFunctions": [{"functionName": "heavy", "complexity": 11, "lineNumber": 1}] }

Compare the complexity of these two versions: 'function a() { return 1; }' and 'function b() { if (true) { return 1; } }'

{ "complexityDelta": 1, "isRegression": true, "newHighComplexityFunctionsCount": 0 }

The tool counts decision points like `if`, `for`, `while`, and logical operators (`&&`, `||`) within a function, then adds 1 to the total count.

Related Connectors