SkillAgentSearch skills...

tree-sitter-analyzer

Cross-language-safe code-intelligence MCP for AI agents: 13 languages, family-gated call graph, blast radius, health grading, 8 facade tools, JSON envelopes, 100% local. Run miswire-audit on your repo.

Install / Use

claude mcp add aimasteracc -- npx -y github:aimasteracc/tree-sitter-analyzer

If the server publishes to npm under a different name, use that package instead — check the repo README.

About this skill
🔌

MCP Server

Model Context Protocol server

Quality Score

87/100

Supported Platforms

Claude Code
Claude Desktop

Tags

🌳 Tree-sitter Analyzer

English | 日本語 | 简体中文

PyPI Python License Coverage Stars Works with Claude Code · Cursor · MCP

Code intelligence AI agents can trust — correct cross-language structure across 20+ languages, agent-native (MCP + CLI).

TSA indexes your codebase with tree-sitter and serves correct call graphs, symbol search, and structural queries to AI coding agents — locally, with no telemetry.

Why it's different:

  • Cross-language correctness is the moat. A name-only index wires Python sorted() to a Swift func sorted. TSA doesn't. ~390× fewer cross-language call-graph mis-wires than alternatives (reproducible audit).
  • Built agent-native. 8 MCP tools, TOON output (~half the size of JSON on bulk/tabular responses), verdict envelopes, and 13 curated Skills — designed for Claude Code, Cursor, and any MCP client.
  • Broad and correctly classified. 13 languages with full call-graph indexing (Python · Go · Rust · Java · JS · TS · C · C++ · C# · Swift · Kotlin · Ruby · PHP), 8 more symbol-indexed or CLI-reachable.

Proof: on HuggingFace tokenizers (Rust+Python+JS+TS), a name-only resolver mis-wires 1,259 call edges — TSA: 0. Run it on your repo in seconds: uvx --from tree-sitter-analyzer miswire-audit .

Upgrading from v1.x? See docs/MIGRATION.md.


Get Started

Requires Python 3.10+ (check: python3 --version). Install from python.org if needed.

Automated install (recommended)

curl -fsSL https://raw.githubusercontent.com/aimasteracc/tree-sitter-analyzer/main/install.sh | bash

Auto-installs uv if missing, detects Claude Desktop / Claude Code / Cursor / VS Code, and writes the MCP entry. Run tree-sitter-analyzer --doctor to verify. One-line install for Claude Code:

claude mcp add tree-sitter-analyzer \
  --env TREE_SITTER_PROJECT_ROOT="$PWD" \
  -- uvx --from "tree-sitter-analyzer[mcp]" tree-sitter-analyzer-mcp

Restart your agent, then say: "Run the index tool with action=status." CLI equivalent (no agent needed): tree-sitter-analyzer --codegraph-status

PyPI / uvx users — install skills: the 13 tsa-* skills are bundled in the wheel. Copy them once with:

tree-sitter-analyzer --install-skills              # into ./.claude/skills/ (this project)
tree-sitter-analyzer --install-skills-global       # into ~/.claude/skills/ (all projects)

Git-clone users already have them under .claude/skills/ — no action needed.

Other agents (Cursor, Copilot, Cline, Continue, Claude Desktop, Roo Code) →

Quick install

1. Install dependencies

# uv (required)
curl -LsSf https://astral.sh/uv/install.sh | sh        # macOS / Linux
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"  # Windows

# fd + ripgrep (required for `search action=content` text search; symbol search uses SQLite FTS5 and needs neither)
brew install fd ripgrep                                # macOS
winget install sharkdp.fd BurntSushi.ripgrep.MSVC      # Windows

2. Install Tree-sitter Analyzer

# Standalone install (persistent CLI command):
uv tool install "tree-sitter-analyzer[all,mcp]"
# — or skip installing entirely: the MCP entry below runs via uvx on demand.
# Inside a uv-managed Python project, use: uv add "tree-sitter-analyzer[all,mcp]"

3. Hook it into your agent

See Supported Agents. Most clients want this MCP server entry:

{
  "mcpServers": {
    "tree-sitter-analyzer": {
      "command": "uvx",
      "args": ["--from", "tree-sitter-analyzer[mcp]", "tree-sitter-analyzer-mcp"],
      "env": { "TREE_SITTER_PROJECT_ROOT": "/absolute/path/to/your/project" }
    }
  }
}

After restart: "Run the index tool with action=status." CLI equivalent (no agent needed): tree-sitter-analyzer --codegraph-status

See the correctness edge on your own repo — no install, no CodeGraph (it re-indexes first; seconds on a small repo, a minute or two on a large one):

uvx --from tree-sitter-analyzer miswire-audit .

It prints how many call edges a name-only code index (the design most tools use) would mis-wire across a language boundary — e.g. a Python sorted() wired to a Swift func sorted — versus how many TSA does (≈0). On HuggingFace tokenizers: 1,259 → 0.


Why Tree-sitter Analyzer

  • Token-efficient on bulk output. Every MCP response uses TOON, a tabular JSON variant that cuts bulk/tabular payloads by roughly half vs raw JSON (measured invariant). Note: small metadata-heavy decision-tool responses are currently ~equal-to-larger than JSON under the present envelope wiring — tracked by a strict-xfail invariant and being corrected in RFC-0018.
  • Verdict envelopes. Every response carries verdict: SAFE | CAUTION | UNSAFE | INFO | REVIEW | WARN | ERROR | NOT_FOUND, so orchestrators branch on outcomes without re-prompting.
  • Project health grading (A–F). Few code-intel tools expose a whole-project quality grade — TSA grades on size / complexity / coverage / duplication / dependencies / structure / git-hotspots in one call.
  • 13 curated workflows (Skills). Pre-baked tool subsets for "find symbol", "trace call chain", "score health", "safe-to-edit before refactor", "PR review", etc.
  • 5 layers of safety. edit action=safe + edit action=guard + constraint DSL + edit action=impact + verdict envelopes — designed so agents know before they touch.
  • Strict CLI superset of CodeGraph, faster indexing, and a one-call query DSL — with an honest cost comparison (below).

Key Features

Pre-indexed code intelligence (CodeGraph parity + superset)

| Capability | TSA tool | Status | |---|---|---| | Symbol search (FTS5 + BM25 ranked) | search action=symbol | ahead — results sorted by relevance score, not file path | | Go-to-def / find-refs / call hierarchy in one call | nav action=navigate | PRIMARY entry point | | Bulk-fetch N related symbols + relationship map | structure action=explore | parity | | Function-level blast radius + risk score | nav action=impact | parity + risk score | | Who-calls-X / what-X-calls | nav action=callers / action=callees | parity | | Index health at-a-glance (+ edge count) | index action=status | ahead — reports total_edges for graph density signal | | Pre-built call graph cache | index action=auto / action=full / action=sync | parity | | Tests affected by a change (CLI) | --affected FILE... | parity |

Tree-sitter Analyzer exclusive

| Capability | TSA tool | Note | |---|---|---| | BM25-ranked symbol search | all search tools | relevance_score on every result (min-max normalized: best=1.0, weakest=0.0); sort(by='confidence') in DSL | | Semantic search (BM25 pre-filtered) | search action=chain (semantic() DSL) | BM25 pre-filter narrows 40k symbols to ~400 before cosine rerank | | Project A–F health grading | health action=project | 7 dimensions (size/complexity/deps/coverage/duplication/structure/git-hotspot), uncommon among code-intel tools | | TOON output | every tool, output_format: "toon" (default) | ~50 % token saving on bulk/tabular output (decision tools tracked by RFC-0018) | | Verdict envelopes | every tool | SAFE/CAUTION/UNSAFE/INFO/WARN/ERROR/NOT_FOUND | | Safe-to-edit gate | edit action=safe / action=guard | refuses high-risk edits before they happen | | Architectural constraint DSL | edit action=constraints | "module A cannot import B" → enforced | | Code health (file-level) | health action=file | block/long-method/smell detection | | Class hierarchy | structure action=class_tree | type-inheritance tree | | Dependency matrix | health action=matrix | module-coupling matrix | | Dead code | health action=dead | transitive unreachable analysis | | Complexity heatmap | health action=heatmap | per-fn cyclomatic + project view | | AST-structural clone detection | viz action=similarity | beyond text similarity | | Mermaid call-graph export | viz action=graph | paste-ready in docs | | UML Mermaid export | viz action=uml | class / package / component / sequence diagrams | | PR review | edit action=pr | AST-diff + semantic classify + blast radius | | agent_summary | every response | next-step hint baked into the envelope | | Synapse cross-file resolver | internal | import-aware, beats regex guessing | | Temporal activation | nav action=lineage | per-symbol git-modification frequency | | One-shot file orientation | project action=smart | health + exports + deps + edit-risk in one call (replaces 3-4 calls) | | Architectural decision journal | project action=journal | persists reasoning across sessions — uncommon among code-intel tools |

Skills (13 curated workflows)

CodeGraph has zero skills. We ship 13 under .claude/skills/tsa-*/:

tsa-landing, tsa-find, tsa-graph, tsa-structure, tsa-deps, tsa-index, tsa-health-watch, tsa-edit-safety, tsa-edit-then-verify, tsa-constraints, tsa-pr-review, tsa-refactor-queue, tsa-temporal.

Each skill ships an allowed-tools subset + procedure recipe + decision-surface schema, so the agent doesn't have to triage 8 tools on every question.

321 CLI flags

Superset of CodeGraph's CLI surface. Highlights:

tree-sitter-analyzer --table full <file>          # method/signature/complexity table
tree-sitter-analyzer --partial-read --start-line N --end-line M <file>
tree-sitter-analyzer --project-health             # A-F grade across the project
# Note: --callers / --callees require the call-graph index — run --full-index first
tree-sitter-analyzer --full-index                 # build call-graph index (run once)
tree-sitter-analyzer --callers <symbol>           # who-calls
tree-sitter-analyzer --codegraph-impact <fn>      # blast radius + risk
tree-sitter-analyzer --affected <file...>         # tests transitively affected
tree-sitter-analyzer --dead-code                  # transitive unreachable
tree-sitter-analyzer --check-constraints          # architectural rules
tree-sitter-analyzer --safe-to-edit <file>        # refuse if risky
tree-sitter-analyzer --uml class                  # Mermaid UML class diagram

Installing the package also registers three standalone search utilities (thin entry points over the same engine, handy in shell pipelines):

list-files <dir>          # fd-style file discovery
search-content <pattern>  # ripgrep-style content search
find-and-grep <pattern>   # two-stage fd + ripgrep

See docs/CODEMAPS/cli.md for the full surface.


How TSA compares to CodeGraph

Call-graph correctness — TSA resolves what CodeGraph mis-wires

Token cost is one axis; a code-intelligence tool's first job is a correct graph.

**Head-to-head on this repo, both tools'

Truncated for display — read the full file on GitHub.

Related Skills

View on GitHub
GitHub Stars50
CategoryAI
Updated21h ago
Forks14

Languages

Python

Security Score

100/100

Audited on Sep 21, 2026

No findings