Skip to main content
Glama
tree-sitter-analyzer

tree-sitter-analyzer

by aimasteracc

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
TREE_SITTER_OUTPUT_PATHNoOptional path for large output write target.
TREE_SITTER_PROJECT_ROOTYesAbsolute path to the project root directory.

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

TSA MCP Routing

This server exposes 8 facade tools. Each takes an action parameter that selects a capability. Use these first for code-intelligence questions — they give indexed, cross-file answers and are cheaper than grep/read loops.

The 8 tools: nav, search, structure, health, edit, project, index, viz.

Intent -> tool + action (START HERE)

Intent

Call

Understand an area / trace a flow from a task

nav action=context

What does a function call (whole tree, one call)

nav action=callee_tree

What calls a function (blast radius, one call)

nav action=caller_tree

Path from function A to function B

nav action=call_path

Who calls X / what X calls (single hop)

nav action=callers / action=callees

Go-to-definition + references for a symbol

nav action=navigate

Find a symbol, class, function, or method

search action=symbol

Class/file structure, overview, signatures

structure

Is the index ready / how big?

index action=status

Edge-kind breakdown of the graph

index action=status (edges_by_kind)

Get pushed when results change

search action=subscribe

File / module dependency questions (risk score, tests bucket)

nav action=impact / structure

Which tests exercise a function

nav action=test_map

Files that historically change with X

nav action=co_change

File discovery

project / search

Differentiators (capabilities grep / one-shot indexers lack)

  • Reactive push (RFC-0001) — search action=subscribe registers a Hyphae selector and hands back a tsa://hyphae/{selector} resource URI. When the watched code changes, the server emits a resource-updated notification, so you re-read the resource instead of re-querying on a poll. search action=unsubscribe cancels it. This is live subscription, not a snapshot.

  • edges_by_kind — index action=status returns a per-edge-kind count (calls / extends / implements / imports …), not just a single total. Use it to see the graph's shape before drilling in.

  • nav action=impact test partition (RFC-0014) — risk score is computed from PRODUCTION call edges only; the result always includes a tests bucket (test_callers_count, test_callees_count). Pass include_tests=true to also receive test_caller_files / test_callee_files (applies to function_impact and risk_score modes).

  • nav action=test_map (RFC-0014 Phase B) — inverts the test-noise problem: returns which test files and test functions exercise a given function. Fields: test_files (sorted paths), test_functions ("file::fn" paste-ready for pytest), edge_count, truncated. Use BEFORE editing to know the test surface.

  • nav action=co_change (RFC-0014 Phase C) — git-history temporal coupling: files that historically change together with a file or symbol, ranked by true association lift. Surfaces structural coupling the call graph cannot see (config+code, schema+handler, proto+stub). Results cached per HEAD. Use BEFORE editing to identify co-change risk.

Default chain for "how does X work / trace a flow" (FOLLOW THIS)

  1. nav action=context — ONE call returns the task's entry points + definition

    • callers + callees + source code blocks. This is the primary tool.

  2. nav action=callee_tree (or caller_tree) — the FULL call tree in ONE call, no per-node iteration.

  3. Answer from those two responses. Only Read a file if a specific line is genuinely missing from the code blocks.

This 2-call chain answers most trace/flow questions. Do NOT scatter the work across search + structure + navigate — that is the slow path.

Stop rules

  • Prefer 2-3 tool calls, then answer.

  • nav action=context already includes callers + callees + source — do not re-fetch them with separate calls.

  • Do NOT loop search or nav action=navigate per symbol — use callee_tree / caller_tree to get the whole tree at once.

  • Do NOT re-verify results with grep or file reads — the AST index is truth.

Anti-patterns (DO NOT)

  • Do NOT use the structure facade to answer a trace/flow question — use nav action=context then nav action=callee_tree.

  • Do NOT chain search -> callers -> callees for an architecture question — nav action=context does all three in one call.

  • Do NOT call nav action=context for a simple "where is X defined?" — use search action=symbol instead.

Small project mode

When index action=status reports fewer than 500 nodes, only nav, search, structure, and index are needed. Skip the heavy-graph and batch capabilities.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": true
}
prompts
{
  "listChanged": true
}
resources
{
  "subscribe": true,
  "listChanged": true
}

Tools

Functions exposed to the LLM to take actions

NameDescription
searchB

Code-intelligence (codegraph-compatible) search facade; multi-hop graph questions (callers then tests, untested callers, impact, depth/path filters) take ONE action=uql call with completeness. Actions: chain, query, select, semantic, subscribe, symbol, text, tql_execute, tql_schema, unsubscribe, uql. Pass action=help with target_action for an exact action schema.

navA

Code-intelligence (codegraph-compatible) navigation facade (multi-hop: search action=uql). Actions: call_path, callee_tree, callees, caller_tree, callers, co_change, context, impact, lineage, navigate, pulse, pulse_batch, resolve, test_map, trace, xref. Pass action=help with target_action for an exact action schema. Cost: action=callers is slow (prefer nav action=context (1-hop, warm)).

structureB

Code-intelligence (codegraph-compatible) structural analysis facade. Actions: analyze, ast_path, class_detail, class_tree, explore, outline, read, signatures, sitemap. Pass action=help with target_action for an exact action schema.

healthA

Code-intelligence (codegraph-compatible) health and analysis facade. Actions: dead, deps, file, heatmap, imports, matrix, middleware, overview, patterns, project, refactor_queue, routes, scale, self, test_gap, unreachable. Pass action=help with target_action for an exact action schema. Cost: action=project is slow (prefer health action=file (one file, warm)).

editB

Code-intelligence (codegraph-compatible) safety and change-management facade. Actions: ast_diff, classify, constraints, guard, impact, mutation_probe, plan_rename, pr, refactor, release_snapshot, rename, safe, verify. Pass action=help with target_action for an exact action schema. Cost: action=safe is slow.

projectC

Code-intelligence (codegraph-compatible) project-intelligence hub. Actions: card, doc_sync, journal, metrics, overview, parser, skills, smart, workflow. Pass action=help with target_action for an exact action schema.

indexB

Code-intelligence (codegraph-compatible) index lifecycle hub. Actions: auto, build, cache, full, knowledge, schema, status, sync. Pass action=help with target_action for an exact action schema.

vizB

Code-intelligence (codegraph-compatible) visualization and similarity facade. Actions: graph, knowledge, similarity, uml. Pass action=help with target_action for an exact action schema.

set_project_pathA

SMART Workflow 'Set' step (FIRST): Set the project root path for security boundaries. Call this before any other tool to ensure correct file resolution and security validation.

Prompts

Interactive templates invoked by user choice

NameDescription
smart_analyzeSMART Workflow: Systematic code analysis for a single file. Recommended for files you haven't seen before.
smart_exploreSMART Workflow: Explore a new project. Get the full picture before diving into code.

Resources

Contextual data attached and managed by the client

NameDescription
code_fileAccess to code file content through URI-based identification
project_statsAccess to project statistics and analysis data
Hyphae selector resultRe-evaluate a Hyphae selector expression and return the current result set. URI produced by search action=subscribe.

TDQS

B3.2/5.0

Scored across 9 tools

Disambiguation2/5

Eight facade tools bundle many actions, and their boundaries are porous: search and nav both advertise multi-hop/impact/UQL, nav and edit both expose impact, viz and index both expose knowledge, and health/project both expose overview. An agent can often justify several entry points for the same question, so misselection is likely despite detailed action lists.

Naming Consistency3/5

Most tools are single-word noun facades (viz, search, nav, edit, health, index, project, structure), but set_project_path is a verb_noun setup tool and abbreviations like viz/nav break the pattern. The convention is mixed but still readable.

Tool Count4/5

Nine top-level tools is a sensible count and the facade grouping keeps the surface navigable. However, each facade hides 8-16 actions, so the effective operation count is much larger than nine and some facades are overstuffed.

Completeness4/5

The surface covers index lifecycle, search/navigation, structural analysis, health, edit/refactor, visualization, and project intelligence, which is broad coverage for a code-intelligence server. No obvious lifecycle dead end exists, though some operations such as test execution or documentation generation are only implied or partial.

Maintenance

ActivityActive
ResponsivenessSyncing