code-analyze-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Native agent tools (regex search, path matching, file reading) handle targeted lookups well.aptu-coder handles the mechanical, non-AI work: mapping directory structure and extracting symbols, so a coding agent's context window is spent reasoning instead of re-deriving structure on every call.
Most code-intelligence tooling for AI agents indexes a codebase into a cloud embedding or vector store and retrieves by similarity search. aptu-coder instead parses the codebase on-device with tree-sitter and serves it locally over MCP: no source code leaves the machine, and retrieval is exact (symbol tables) rather than approximate (nearest-neighbor similarity).
Benchmarks
Paired comprehension tasks on Claude Code (MCP mode vs native shell search). Methodology: Django auth migration (v12) and OpenFAST AeroDyn integration audit (v13).
Task | Mode | Sonnet 4.6 | Haiku 4.5 | Savings |
Django (Python) | MCP | 112k tokens, $0.39 | 406k tokens, $0.42 | 59% fewer tokens, 59% cheaper (Sonnet) |
Django (Python) | Native | 276k tokens, $0.95 | 473k tokens, $0.53 | 14% fewer tokens, 21% cheaper (Haiku) |
OpenFAST (Fortran) | MCP | 472k tokens, $1.65 | 687k tokens, $0.72 | 46% fewer tokens, 42% cheaper (Sonnet) |
OpenFAST (Fortran) | Native | 877k tokens, $2.85 | 2162k tokens, $2.21 | 68% fewer tokens, 68% cheaper (Haiku) |
A real end-to-end multi-agent run against this repository itself: five refactoring issues (#1578–#1582) fixed by the coder skill in one orchestrated session — 23 subagent spawns (5 scout, 1 guard, 10 build, 7 check), ~1h42m, three human interventions — producing PRs #1584–#1588, all merged with CI green. Case study.
Scope of the benchmark claims
The token-savings figures above come from single, focused comprehension tasks where the agent used aptu-coder instead of shell search. Agentic coding loops have bash and ripgrep and can search the repo directly. The v19 benchmark program (N=20 paired sessions, pre-registered claim gate) measured aptu-coder in those loops: no measurable answer-quality gain over bash + ripgrep on structural fan-in tasks (pooled paired F1 diff mean -0.071, 95% CI [-0.179, +0.038]; gate NOT-SUPPORTED); tool activation itself was reliable when tools were surfaced directly. Recommended uses: premise grounding for multi-agent workflows, and non-agentic MCP consumers (IDE assistants, CI jobs, scoring pipelines).
Related MCP server: CodeGraphMCPServer
Overview
Figure 1: An AI agent connects over MCP to aptu-coder, whose analyze tools feed tree-sitter parsing into the formatter.
aptu-coder is a comprehension layer for coding agents: it gives an agent harness precise structural context about a codebase, directory trees, and symbol definitions, without the agent reading raw files or re-deriving structure on every call. That prevents context starvation on large or unfamiliar codebases while keeping the result set small enough to fit the model's context window. It supports 18 languages (see Supported Languages) and integrates with any MCP-compatible orchestrator.
Structural context is built once and reused: an on-disk cache keyed by blake3 content hashes keeps results correct across concurrent writes. For consumers that hold source text without an on-disk path, aptu-coder-core also exposes analyze_str as a public Rust library API (see ARCHITECTURE.md).
Further reading on the design philosophy, from the author's blog: The Agentic SDLC Governance Stack, Context Engineering for Multi-Agent Reliability, and Orchestrating AI Agents: Subagent Architecture.
Supported Languages
Astro, C/C++, C#, CSS, Fortran, Go, HTML, Java, JavaScript, JSON, Kotlin, Markdown, Python, Rust, TOML, TSX, TypeScript, YAML. The full extension map lives in crates/aptu-coder-core/src/lang.rs.
Installation
Homebrew (macOS and Linux)
brew install clouatre-labs/tap/aptu-coderUpdate: brew upgrade aptu-coder
cargo-binstall (no Rust required)
cargo binstall aptu-codercargo install (requires Rust toolchain)
cargo install aptu-coderQuick Start
Build from source
cargo build --releaseThe binary is at target/release/aptu-coder.
Configure MCP Client
stdio (default) — the client spawns and owns the server process; this works with orchestrators that spawn delegates (goose, pi) as well as single clients:
claude mcp add --transport stdio aptu-coder -- aptu-coderOr add manually to .mcp.json at your project root (shared with your team via version control):
{
"mcpServers": {
"aptu-coder": {
"command": "aptu-coder",
"args": []
}
}
}Streamable HTTP (optional) — runs a single shared server process instead of one per client. Only worth it if you specifically want a daemon-style setup:
aptu-coder --port 49200 # or: brew services start aptu-coder
claude mcp add --transport http aptu-coder http://127.0.0.1:49200/mcpFor goose, add to ~/.config/goose/config.yaml:
extensions:
aptu-coder:
type: streamable_http
uri: http://127.0.0.1:49200/mcp
name: aptu-coder
timeout: 300Tools
All optional parameters may be omitted. analyze_directory, analyze_file, and analyze_module accept summary (compact output, auto-triggers above 50K chars) and cursor (pagination token). Page size is server-owned; there is no client page_size parameter (passing one returns INVALID_PARAMS).
analyze_directory-- directory tree with LOC, function, and class counts; respects.gitignoreanalyze_file-- functions, classes, and imports with signatures and line ranges; graceful fallback for unsupported extensionsanalyze_module-- lightweight function and import index (~75% smaller thananalyze_file)edit_overwrite-- create or overwrite a file; creates parent directoriesedit_replace-- replace a unique exact text block (or all occurrences withreplace_all); batch formedits[]applies multiple replacements atomically; optionalexpected_content_hashrejects stale editsexec_command-- run a shell command; output is capped, filtered, and returned with exit code; cancelled requests kill the command
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 appends 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_file path: /my/project/src/lib.rs cursor: eyJvZmZzZXQiOjUwfQ==exec_command output caps
exec_command applies three independent byte-level caps to prevent large command outputs from flooding the context:
stdout keeps the last 30,000 chars, stderr the last 10,000 (tail-preserving, so errors appear at the end), and the combined output_text is capped at 50,000 chars as a safety net after interleaving.
The 30k stdout cap is data-driven: analysis of 27,981 observed exec_command calls shows only 0.33% exceed this limit. When any cap fires, output_truncated: true is set in the response and recorded in the JSONL metrics.
Recovering capped output: when output is capped, the response includes MCP resource links (aptu-overflow://slot-{seq}/stdout, /stderr, /interleaved) pointing to the full raw capture for that invocation (last-run-wins); read them via resources/read. If a filter capped the output, a hint line points to the pre-filter capture file.
A server-owned post-exit drain window (500 ms) waits for any background subprocess still holding the pipe open. If it expires before the pipe closes, exit_code is null and output_truncated: true is set.
exec_command output filters
A built-in filter table suppresses per-file noise from chatty CLI tools before output reaches the model. Filters apply to stdout, stderr, and interleaved output on success only; raw output is always preserved on failure.
Built-in rules cover the usual suspects: git pull/fetch/push strip diff-stat, remote-progress, and ref noise; git log/status cap at 20 lines; git show strips patch hunks; git diff strips ANSI escapes; git commit/add strip hook output; cargo build/test strip Compiling/Checking/Fresh progress lines. Clean output collapses to a short ok confirmation.
Project-local rules can be added in .aptu/filters.toml. Parse errors and unrecognized schema_version values (version != 1) fall back to the built-in table with a logged warning; no crash occurs. When a filter fires, filter_applied in structuredContent identifies which rule matched.
Non-Interactive Pipelines
In single-pass subagent sessions, prompt caches are written but never reused. Benchmarks showed MCP responses writing ~2x more to cache than native-only workflows, adding cost with no quality gain. Set DISABLE_PROMPT_CACHING=1 (or DISABLE_PROMPT_CACHING_HAIKU=1 for Haiku-specific pipelines) to avoid this overhead.
The server's own instructions are deliberately minimal, a single short paragraph: start with analyze_directory for a package/module map, then use analyze_module/analyze_file for per-file detail, with a pointer to docs/METRICS.md for JSONL metrics and jq recipes. MCP clients that surface server instructions will present this guidance automatically to the agent.
Environment Variables
Cache and runtime
Variable | Default | Description |
|
| LRU cache size for directory-analysis results. |
|
| Directory for the L2 analysis disk cache. Created automatically if it does not exist. |
| unset | Set to |
|
| LRU cache size for file-analysis results. |
| unset | Absolute path for a one-shot JSONL metrics export on shutdown. |
| unset | Port for streamable HTTP mode. Equivalent to |
| unset | Bearer token for Streamable HTTP transport authentication. A warning is logged if the value is fewer than 32 characters. |
| unset | Marks the session origin for JSONL metrics: |
| unset | Shell for |
Observability
For the JSONL schema, OTel configuration, and span attribute policy, see:
OBSERVABILITY.md (repository root)
Documentation
Blog - Design philosophy and agent-harness engineering behind aptu-coder
AGENTS.md - Contributor reference: project structure, commands, rmcp footguns, tool parameter constraints
ARCHITECTURE.md - Design goals, module map, data flow, language handler system, caching strategy
CONTRIBUTING.md - Development workflow, commit conventions, PR checklist
DESIGN-GUIDE.md - Design decisions, rationale, and replication guide for building high-performance MCP servers
MCP Best Practices - Best practices for agentic loops, orchestration patterns, MCP tool design, memory management, and safety controls
METRICS.md - Metrics schema, JSONL format, and retention policy
ROADMAP.md - Development history and future direction
SECURITY.md - Security policy and vulnerability reporting
License
Apache-2.0. See LICENSE for details.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Repository knowledge graph MCP server for codebase understanding and debugging.
Shared context for your codebase: a hosted code knowledge graph over MCP. Free plan, OAuth sign-up.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA lightning-fast, language-agnostic code analysis MCP (Model Context Protocol) server built in Rust9-
- AlicenseNot gradedqualityCmaintenanceA lightweight, zero-configuration MCP server for source code analysis with GraphRAG capabilities, enabling structural understanding and efficient code completion from MCP-compatible AI tools.34 PyPI14MIT
- AlicenseNot gradedqualityCmaintenanceA persistent, tree-sitter-backed code knowledge cache MCP server that reduces token usage by storing parsed structure and enabling fast symbol lookup, inheritance graph, call graph, and semantic search.1MIT
- AlicenseAqualityDmaintenanceUniversal MCP server that analyzes any codebase and provides structured context to AI assistants. Dynamic, accurate, and token-efficient.18MIT