Time Complexity MCP: Static Analysis Tool Feeds Big-O Complexity to AI Coding Agents

✍️ OpenClawRadar📅 Published: February 27, 2026🔗 Source
Time Complexity MCP: Static Analysis Tool Feeds Big-O Complexity to AI Coding Agents
Ad

Time Complexity MCP is an MCP server that performs static analysis on code to determine Big-O time complexity, then feeds those values directly to AI coding agents. The tool bypasses the token consumption and potential inaccuracies that occur when frontier models attempt to analyze complexity themselves.

How It Works

The server parses code into Abstract Syntax Trees (ASTs) using tree-sitter, then analyzes them to detect:

  • Loop nesting patterns
  • Recursion patterns
  • Known standard library costs

It reports per-function Big-O complexity with line annotations that AI agents can access as a tool.

What It Detects

The tool identifies specific complexity patterns:

  • .contains() inside a for loop → O(n²)
  • .sort() with .indexOf() in the comparator → O(n² log n)
  • Branching recursion like fibonacci → O(2ⁿ)
  • Constant-bound loops like for i in range(10) → O(1)
Ad

Supported Languages

The tool currently supports JavaScript, TypeScript, Python, Java, Kotlin, and Dart.

Real-World Application

The developer ran the tool on its own codebase and found:

  • O(n³) in the directory scanner
  • O(n²) in the formatting utils

These issues were fixed based on the tool's own report, demonstrating practical self-improvement.

Availability

Time Complexity MCP is open source with prebuilt releases available at https://github.com/Luzgan/time-complexity-mcp.

📖 Read the full source: r/ClaudeAI

Ad

👀 See Also