code-analyze-mcp

by clouatre-labs

5 stars
223 downloads
Not rated
GitHub

About

aptu-coder: MCP server for AST analysis, call graphs, and code structure (tree-sitter)

Details

Author
clouatre-labs
GitHub stars
5
Downloads
223
Categories
Developer Tools

- Offloads mechanical code analysis, reducing token usage and costs
- Supports 18 languages including Python, Rust, TypeScript, and C++
- Provides paginated outputs for large codebases
- Includes built-in output filters for common CLI tools
- OpenSSF Silver certified for security best practices
- Offers two transport modes: streamable HTTP and stdio

Install via Homebrew (brew install clouatre-labs/tap/aptu-coder), cargo-binstall, or cargo install aptu-coder. Configure your MCP client with either streamable HTTP (recommended for multi-agent setups) or stdio transport. The server exposes tools such as analyze_directory, analyze_file, analyze_symbol, edit_overwrite, edit_replace, and exec_command.

<p align="center">

<h1 align="center">aptu-coder</h1>

<p align="center">
<a href="https://crates.io/crates/aptu-coder">crates.io</a>
<a href="https://slsa.dev">SLSA Level 3</a>
<a href="https://www.bestpractices.dev/projects/12275">OpenSSF Best Practices</a>
</p>

<p align="center">Standalone MCP server for code structure analysis using tree-sitter. OpenSSF silver certified: fewer than 1% of open source projects reach this level.</p>

<!-- mcp-name: io.github.clouatre-labs/aptu-coder -->

> [!NOTE]
> Native agent tools (regex search, path matching, file reading) handle targeted lookups well. aptu-coder handles the mechanical, non-AI work: mapping directory structure, extracting symbols, and tracing call graphs. Offloading this to a dedicated tool reduces token usage and speeds up coding with better accuracy.

Benchmarks

Auth migration task on Claude Code against Django (Python) source tree. Full methodology.

| Mode | Sonnet 4.6 | Haiku 4.5 |
|---|---|---|
| MCP | 112k tokens, $0.39 | 406k tokens, $0.42 |
| Native | 276k tokens, $0.95 | 473k tokens, $0.53 |
| Savings | 59% fewer tokens, 59% cheaper | 14% fewer tokens, 21% cheaper |

AeroDyn integration audit task on Claude Code against OpenFAST (Fortran) source tree. Full methodology.

| Mode | Sonnet 4.6 | Haiku 4.5 |
|---|---|---|
| MCP | 472k tokens, $1.65 | 687k tokens, $0.72 |
| Native | 877k tokens, $2.85 | 2162k tokens, $2.21 |
| Savings | 46% fewer tokens, 42% cheaper | 68% fewer tokens, 68% cheaper |

Overview

aptu-coder is a Model Context Protocol server that gives AI agents precise structural context about a codebase: directory trees, symbol definitions, and call graphs, without reading raw files. It supports 18 languages (see Supported Languages) and integrates with any MCP-compatible orchestrator.

Supported Languages

All languages are enabled by default. Disable individual languages at compile time via Cargo feature flags.

| Language | Extensions | Feature flag |
|----------|------------|--------------|
| Astro | .astro | always-on (regex via TypeScript frontmatter extractor) |
| C/C++ | .c, .cc, .cpp, .cxx, .h, .hpp, .hxx | lang-cpp |
| C# | .cs | lang-csharp |
| CSS | .css | lang-css (tree-sitter; regex fallback when disabled) |
| Fortran | .f, .f77, .f90, .f95, .f03, .f08, .for, .ftn | lang-fortran |
| Go | .go | lang-go |
| HTML | .html, .htm | lang-html (stub; no extraction) |
| Java | .java | lang-java |
| JavaScript | .js, .mjs, .cjs | lang-javascript |
| JSON | .json | always-on (regex; first-level key extraction) |
| Kotlin | .kt, .kts | lang-kotlin |
| Markdown | .md, .mdx | lang-markdown |
| Python | .py | lang-python |
| Rust | .rs | lang-rust |
| TOML | .toml | always-on (regex; section header extraction) |
| TSX | .tsx | lang-tsx |
| TypeScript | .ts | lang-typescript |
| YAML | .yaml, .yml | lang-yaml (tree-sitter; regex fallback when disabled) |

Installation

Homebrew (macOS and Linux)

brew install clouatre-labs/tap/aptu-coder

Update: brew upgrade aptu-coder

cargo-binstall (no Rust required)

cargo binstall aptu-coder

cargo install (requires Rust toolchain)

cargo install aptu-coder

Quick Start

Build from source

cargo build --release

The binary is at target/release/aptu-coder.

Configure MCP Client

Two transports are available. Streamable HTTP is recommended when using orchestrators that spawn delegates (e.g. goose coder): a single server process is shared across the orchestrator and all agents, eliminating extension-drift that occurs when each stdio subprocess gets its own isolated instance.

Streamable HTTP (recommended for multi-agent setups)

With Homebrew, one command starts the server on login and keeps it running:

brew services start aptu-coder

The Homebrew formula starts the server on port 49200 by default. Then add the extension once to ~/.config/goose/config.yaml:

extensions:
  aptu-coder:
    type: streamable_http
    uri: http://127.0.0.1:49200/mcp
    name: aptu-coder
    timeout: 300

Or for Claude Code:

claude mcp add --transport http aptu-coder http://127.0.0.1:49200/mcp

To use a different port, set APTU_CODER_PORT before restarting:

APTU_CODER_PORT=4000 brew services restart aptu-coder

To start directly without brew services:

aptu-coder --port 49200

or equivalently

APTU_CODER_PORT=49200 aptu-coder

stdio (single-client use)

Suitable when only one process needs the server. The client owns the process lifecycle and spawns it automatically:

claude mcp add --transport stdio aptu-coder -- aptu-coder

Or add manually to .mcp.json at your project root (shared with your team via version control):

{
  "mcpServers": {
    "aptu-coder": {
      "command": "aptu-coder",
      "args": []
    }
  }
}

Tools

All optional parameters may be omitted. Shared optional parameters for analyze_directory, analyze_file, and analyze_symbol:

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| summary | boolean | auto | Compact output; auto-triggers above 50K chars |
| cursor | string | -- | Pagination cursor from a previous response's next_cursor |
| page_size | integer | 100 | Items per page |

| Tool | Purpose | Languages |
|------|---------|-----------|
| analyze_directory | Directory tree with LOC, function, and class counts; respects .gitignore | all |
| analyze_file | Functions, classes, and imports with signatures and line ranges; returns graceful fallback (line count, file head, no AST) for unsupported extensions | all |
| analyze_module | Lightweight function and import index (~75% smaller than analyze_file); returns graceful fallback (empty index with note) for unsupported extensions | all |
| analyze_symbol | Call graph for a named symbol across a directory; callers, callees, call depth | all |
| edit_overwrite | Create or overwrite a file; creates parent directories | any file |
| edit_replace | Replace a unique exact text block; errors if zero or multiple matches; empty new_text deletes the block; CRLF normalized before matching | all |
| exec_command | Run a shell command; returns stdout, stderr, exit code; output capped and filtered; optional timeout_secs (kill on expiry) and drain_timeout_secs (post-exit drain window); heredoc rejected before spawn (file-write pattern, stdin-consuming flag, stdin parameter conflict, or missing closing delimiter) | any |

Tool parameters, constraints, and examples are available via your MCP client's tool inspector or tools/list response.

Output Management

For large codebases, several mechanisms prevent context overflow.

Pagination

analyze_file and analyze_symbol append a NEXT_CURSOR: line when output is truncated. Pass the token back as cursor to fetch the next page. summary=true and cursor are mutually exclusive; passing both returns an error.

# Response ends with:
NEXT_CURSOR: eyJvZmZzZXQiOjUwfQ==

Fetch next page:

analyze_symbol path: /my/project symbol: my_function cursor: eyJvZmZzZXQiOjUwfQ==

exec_command output caps

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.