Time Complexity MCP

Time Complexity MCP

time-complexity-mcp•byluzgan

An MCP server that estimates Big-O time complexity of source code via static AST analysis, detecting loops, recursion, and known stdlib calls with per-function and line-level annotations.

License: MIT•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Exposes MCP tools to analyze a file, a single function, a directory, or a cloned GitHub repository, plus list supported languages.
  • •Detects loop nesting with depth tracking and treats constant-bound loops as O(1).
  • •Distinguishes linear recursion from branching recursion such as fibonacci, which it reports as O(2^n).
  • •Performs static analysis only, parsing code into ASTs without executing or importing it, and reads files read-only.

BEST FOR

  • •Having AI coding assistants like Claude Code or GitHub Copilot report Big-O complexity of specific functions or files on request.
  • •Scanning an entire codebase to find the most complex functions as optimization hotspots.

ABOUT TIME-COMPLEXITY-MCP

Time Complexity MCP is cataloged as an MCP server attributed to luzgan. An MCP server that estimates Big-O time complexity of source code via static AST analysis, detecting loops, recursion, and known stdlib calls with per-function and line-level annotations. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Time Complexity MCP are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Which programming languages does it support?

JavaScript, TypeScript, Dart, Kotlin, Java, Python, PHP, and Go.

Does analyzing a GitHub repository require anything installed?

The analyze_github_repo tool clones the repository and requires git in PATH.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 265f52e9e012 · 采集于 2026-11-13 14:13:00 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

Time Complexity MCP

An MCP server that estimates Big-O time complexity of your code through static analysis. It parses source files into ASTs using tree-sitter, detects loops, recursion, and known stdlib calls, then reports per-function complexity with line-level annotations.

Built for AI coding assistants — works with Claude Code and GitHub Copilot.

Supported Languages

LanguageExtensionsGrammar
JavaScript.js, .mjs, .cjs, .jsxtree-sitter-javascript
TypeScript.ts, .tsxtree-sitter-typescript
Dart.dartvendor NAPI binding
Kotlin.kt, .ktstree-sitter-kotlin
Java.javatree-sitter-java
Python.pytree-sitter-python
PHP.phptree-sitter-php
Go.gotree-sitter-go

What It Detects

  • Loop nesting — for, while, do-while with depth tracking. Constant-bound loops (e.g., for i in range(10)) are recognized as O(1).
  • Recursion — linear recursion (O(n)) vs branching recursion like fibonacci (O(2^n)).
  • Known stdlib methods — .sort() as O(n log n), .filter()/.map() as O(n), .push()/.pop() as O(1), etc. Each language has its own patterns.
  • Combined complexity — an O(n) method inside an O(n) loop correctly reports O(n^2).

Tools

The server exposes 5 MCP tools:

ToolDescription
analyze_fileAnalyze all functions in a source file. Returns per-function Big-O with reasoning and line annotations.
analyze_functionAnalyze a single function by name or line number.
analyze_directoryScan a directory for all supported files. Returns a summary with hotspots (top 5 most complex functions).
analyze_github_repoClone a GitHub repo and analyze complexity. Accepts owner/repo or full URL. Requires git in PATH.
get_supported_languagesList supported languages with file extensions.

Setup

Download the prebuilt bundle for your platform from the latest release:

PlatformFile
macOS (Apple Silicon)time-complexity-mcp-darwin-arm64-v*.tar.gz
Linux x64time-complexity-mcp-linux-x64-v*.tar.gz
Linux arm64time-complexity-mcp-linux-arm64-v*.tar.gz
Windows x64time-complexity-mcp-win32-x64-v*.zip

Extract and configure:

# macOS / Linux
tar xzf time-complexity-mcp-darwin-arm64-v*.tar.gz
# Windows
Expand-Archive time-complexity-mcp-win32-x64-v*.zip

No C++ compiler or npm install required — just Node.js 18+. The analyze_github_repo tool also requires git in PATH.

Install from Source

Requires Node.js 18+ and a C++ compiler (Xcode CLI tools on macOS, build-essential on Linux).

git clone https://github.com/Luzgan/time-complexity-mcp.git
cd time-complexity-mcp
npm install
npm run build

The postinstall script automatically builds the vendor Dart grammar.

Configure with Claude Code

Add to your project's .mcp.json (or ~/.claude.json for global access):

{
  "mcpServers": {
    "time-complexity": {
      "type": "stdio",
      "command": "node",
      "args": ["/absolute/path/to/time-complexity-mcp/dist/index.js"]
    }
  }
}

Then restart Claude Code. The tools analyze_file, analyze_function, analyze_directory, analyze_github_repo, and get_supported_languages will be available automatically.

Configure with GitHub Copilot (VS Code)

Add to .vscode/mcp.json in your project:

{
  "servers": {
    "time-complexity": {
      "type": "stdio",
      "command": "node",
      "args": ["${workspaceFolder}/dist/index.js"]
    }
  }
}

If the MCP lives outside your workspace, replace ${workspaceFolder}/dist/index.js with the absolute path.

Usage Examples

Once configured, your AI assistant can call the tools directly.

Analyze a file

> Analyze the complexity of src/utils/sort.ts

Returns each function with its Big-O, reasoning, and line-level annotations:

bubbleSort (lines 1-10): O(n^2)
  Found 2 variable-bound loop(s), max nesting depth: 2. Overall: O(n^2).

  Line annotations:
    Line 2: O(n) — for_statement loop (nesting depth: 1)
    Line 3: O(n^2) — for_statement loop (nesting depth: 2)

Analyze a single function

> What's the complexity of the fibonacci function in recursion.py?

Analyze a GitHub repository

> Analyze the complexity of facebook/react

or with a full URL:

> Analyze https://github.com/expressjs/express, focus on the lib/ directory

Clones the repo temporarily, analyzes it, and returns results with repo-relative file paths. Requires git installed.

Scan an entire codebase

> Scan src/ for complexity hotspots

Returns a summary with the top 5 most complex functions across all files:

Files analyzed: 27
Total functions: 150

Breakdown:
  O(1):       102
  O(n):        40
  O(n log n):   1
  O(n^2):       4
  O(n^3):       2
  O(2^n):       1

Hotspots:
  1. src/analyzer/base-analyzer.ts → walk: O(2^n)
  2. src/tools/analyze-directory.ts → analyzeDirectory: O(n^3)
  ...

Architecture

src/
  index.ts                  # Entry point — stdio MCP transport
  server.ts                 # MCP tool registration
  analyzer/
    base-analyzer.ts        # Abstract base class (template method pattern)
    types.ts                # Core types (BigOComplexity, FunctionNode, etc.)
    complexity.ts           # Complexity arithmetic (max, multiply, fromDepth)
  languages/
    index.ts                # Language registry
    javascript/             # JS/TS analyzer
    dart/                   # Dart analyzer
    kotlin/                 # Kotlin analyzer
    java/                   # Java analyzer
    python/                 # Python analyzer
    php/                    # PHP analyzer
    go/                     # Go analyzer
  tools/                    # MCP tool implementations
  utils/                    # File I/O & formatting
vendor/
  tree-sitter-dart/         # Custom NAPI binding for Dart grammar
tests/
  *.test.ts                 # Per-language test suites (99 tests total)
  fixtures/                 # Sample source files

Each language analyzer implements 9 template methods from BaseAnalyzer:

getGrammar()              → tree-sitter grammar object
getFunctionNodeTypes()    → AST node types for functions
getLoopNodeTypes()        → AST node types for loops
getCallNodeTypes()        → AST node types for calls (e.g., "call_expression", "method_invocation", "call")
getKnownMethods()         → stdlib method complexity patterns
extractFunctionName()     → function name from AST node
extractParameters()       → parameter names from AST node
isConstantLoop()          → detect constant-bound loops
getCallName()             → function/method name from call node

Development

npm run build       # Compile TypeScript (also type-checks)
npm test            # Run all 99 tests
npm run test:watch  # Watch mode
npm run dev         # Run server via tsx (no build needed)

Security

  • Static analysis only. Code is parsed into ASTs and inspected — never evaluated, executed, or imported.
  • Read-only file access. Source files are read for parsing. Nothing is written, modified, or deleted.
  • Network access (opt-in). The analyze_github_repo tool invokes git clone to fetch public GitHub repos. All other tools run locally with no network access. Clone URLs are restricted to HTTPS GitHub URLs only.
  • Trusted native addons. Tree-sitter grammars are compiled NAPI addons from verified sources.

License

MIT

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Time Complexity MCP from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/time-complexity-mcp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools