by aimasteracc
Scalable multi‑language code analysis framework built on Tree‑sitter, operable through a command‑line interface or as an MCP server for AI assistants.
Tree Sitter Analyzer provides deep, language‑aware parsing and analysis of source code across more than a dozen programming languages. It leverages Tree‑sitter’s concrete syntax trees to extract structural information, compute metrics, and generate AI‑friendly summaries, making large codebases searchable and understandable for both humans and AI assistants.
CLI
uv package manager (required).\
curl -LsSf https://astral.sh/uv/install.sh | sh
uv add "tree-sitter-analyzer[all,mcp]"
uv run tree-sitter-analyzer path/to/File.java --summary
uv run tree-sitter-analyzer path/to/File.java --query-key methods --filter "public=true"
MCP Server Add the following snippet to your AI assistant’s MCP configuration (Claude Desktop, Cursor, Roo Code, etc.):
{
"mcpServers": {
"tree-sitter-analyzer": {
"command": "uvx",
"args": ["--from", "tree-sitter-analyzer[mcp]", "tree-sitter-analyzer-mcp"],
"env": {
"TREE_SITTER_PROJECT_ROOT": "/path/to/your/project",
"TREE_SITTER_OUTPUT_PATH": "/path/to/output/directory"
}
}
}
}
After restarting the assistant, you can issue prompts such as “Please set the project root directory to: /my/project”.
fd and content search with ripgrep.mypy, and ≈100 % coverage.Q: Do I need to install Tree‑sitter separately?
A: No. The analyzer bundles the required grammar parsers; you only need uv (or Python ≥3.10) and the optional fd/ripgrep tools for search functionality.
Q: Can I extend support to additional languages?
A: Yes. Adding a new Tree‑sitter grammar and declaring it in the extra section of pyproject.toml will make it available.
Q: How does token reduction work?
A: The tool extracts only the syntactic elements requested (e.g., method signatures) and encodes them in a compact JSON format before sending to the LLM.
Q: Is the MCP server secure?
A: The server respects the TREE_SITTER_PROJECT_ROOT environment variable, preventing access outside the defined project boundary.
Q: What CI commands should I use?
A: Typical steps: uv sync --extra all --extra mcp, then uv run pytest and uv run python check_quality.py.
🚀 Enterprise-Grade Code Analysis Tool for the AI Era - Deep AI Integration · Powerful Search · 15 Languages · Intelligent Analysis
📖 Full Changelog for complete version history.
Demo GIF coming soon - showcasing AI integration with SMART workflow
# Install uv (required)
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# Install fd + ripgrep (required for search features)
brew install fd ripgrep # macOS
winget install sharkdp.fd BurntSushi.ripgrep.MSVC # Windows
📖 Detailed Installation Guide for all platforms.
uv run tree-sitter-analyzer --show-supported-languages
Configure your AI assistant to use Tree-sitter Analyzer via MCP protocol.
Add to your MCP configuration:
{
"mcpServers": {
"tree-sitter-analyzer": {
"command": "uvx",
"args": [
"--from", "tree-sitter-analyzer[mcp]",
"tree-sitter-analyzer-mcp"
],
"env": {
"TREE_SITTER_PROJECT_ROOT": "/path/to/your/project",
"TREE_SITTER_OUTPUT_PATH": "/path/to/output/directory"
}
}
}
}
Configuration file locations:
%APPDATA%\Claude\claude_desktop_config.json (Windows) / ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)After restart, tell the AI: Please set the project root directory to: /path/to/your/project
📖 MCP Tools Reference for complete API documentation.
uv add "tree-sitter-analyzer[all,mcp]" # Full installation
# 1. Analyze file structure
uv run tree-sitter-analyzer examples/BigService.java --table full
# 2. Quick summary
uv run tree-sitter-analyzer examples/BigService.java --summary
# 3. Extract code section
uv run tree-sitter-analyzer examples/BigService.java --partial-read --start-line 93 --end-line 106
# 4. Find files and search content
uv run find-and-grep --roots . --query "class.*Service" --extensions java
# 5. Query specific elements
uv run tree-sitter-analyzer examples/BigService.java --query-key methods --filter "public=true"
╭─────────────────────────────────────────────────────────────╮
│ BigService.java Analysis │
├─────────────────────────────────────────────────────────────┤
│ Total Lines: 1419 | Code: 906 | Comments: 246 | Blank: 267 │
│ Classes: 1 | Methods: 66 | Fields: 9 | Complexity: 5.27 avg │
╰─────────────────────────────────────────────────────────────╯
📖 Complete CLI Reference for all commands and options.
| Language | Support Level | Key Features |
|---|---|---|
| Java | ✅ Complete | Spring, JPA, enterprise features |
| Python | ✅ Complete | Type annotations, decorators |
| TypeScript | ✅ Complete | Interfaces, types, TSX/JSX |
| JavaScript | ✅ Complete | ES6+, React/Vue/Angular |
| C# | ✅ Complete | Records, async/await, attributes |
| SQL | ✅ Enhanced | Tables, views, procedures, triggers |
| HTML | ✅ Complete | DOM structure, element classification |
| CSS | ✅ Complete | Selectors, properties, categorization |
| Go | ✅ Complete | Structs, interfaces, goroutines |
| Rust | ✅ Complete | Traits, impl blocks, macros |
| Kotlin | ✅ Complete | Data classes, coroutines |
| PHP | ✅ Complete | PHP 8+, attributes, traits |
| Ruby | ✅ Complete | Rails patterns, metaprogramming |
| YAML | ✅ Complete | Anchors, aliases, multi-document |
| Markdown | ✅ Complete | Headers, code blocks, tables |
📖 Features Documentation for language-specific details.
| Feature | Description | Learn More |
|---|---|---|
| SMART Workflow | Set-Map-Analyze-Retrieve-Trace methodology | Guide |
| MCP Protocol | Native AI assistant integration | API Docs |
| Token Optimization | Up to 95% token reduction | Features |
| File Search | fd-based high-performance discovery | CLI Reference |
| Content Search | ripgrep regex search | CLI Reference |
| Security | Project boundary protection | Architecture |
| Metric | Value |
|---|---|
| Tests | 4,864 passed ✅ |
| Coverage | |
| Type Safety | 100% mypy compliance |
| Platforms | Windows, macOS, Linux |
# Run tests
uv run pytest tests/ -v
# Generate coverage report
uv run pytest tests/ --cov=tree_sitter_analyzer --cov-report=html
git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
cd tree-sitter-analyzer
uv sync --extra all --extra mcp
uv run pytest tests/ -v # Run tests
uv run python check_quality.py --new-code-only # Quality check
uv run python llm_code_checker.py --check-all # AI code check
📖 Architecture Guide for system design details.
We welcome contributions! See Contributing Guide for development guidelines.
If this project helps you, please give us a ⭐ on GitHub!
@o93 - Lead Sponsor supporting MCP tool enhancement, test infrastructure, and quality improvements.
MIT License - see LICENSE file.
| Document | Description |
|---|---|
| Installation Guide | Setup for all platforms |
| CLI Reference | Complete command reference |
| SMART Workflow | AI-assisted analysis guide |
| MCP Tools API | MCP integration details |
| Features | Language support details |
| Architecture | System design |
| Contributing | Development guidelines |
| Changelog | Version history |
🎯 Built for developers working with large codebases and AI assistants
Making every line of code understandable to AI, enabling every project to break through token limitations
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.