Skip to content

A scalable, multi-language code analysis framework based on Tree-sitter, usable both as a CLI tool and an MCP server.

Notifications You must be signed in to change notification settings

aimasteracc/tree-sitter-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒณ Tree-sitter Analyzer

English | ๆ—ฅๆœฌ่ชž | ็ฎ€ไฝ“ไธญๆ–‡

Python Version License Tests Coverage PyPI Version GitHub Stars

๐Ÿš€ Enterprise-Grade Code Analysis Tool for the AI Era - Deep AI Integration ยท Powerful Search ยท 15 Languages ยท Intelligent Analysis


โœจ What's New in v1.9.17

  • New Languages: Go, Rust, Kotlin, YAML support added with full feature extraction
  • 4,864 tests with 100% pass rate

๐Ÿ“– Full Changelog for complete version history.


๐ŸŽฌ See It In Action

Demo GIF coming soon - showcasing AI integration with SMART workflow


๐Ÿš€ 5-Minute Quick Start

Prerequisites

# 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.

Verify Installation

uv run tree-sitter-analyzer --show-supported-languages

๐Ÿค– AI Integration

Configure your AI assistant to use Tree-sitter Analyzer via MCP protocol.

Claude Desktop / Cursor / Roo Code

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:

  • Claude Desktop: %APPDATA%\Claude\claude_desktop_config.json (Windows) / ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
  • Cursor: Built-in MCP settings
  • Roo Code: MCP configuration

After restart, tell the AI: Please set the project root directory to: /path/to/your/project

๐Ÿ“– MCP Tools Reference for complete API documentation.


๐Ÿ’ป Common CLI Commands

Installation

uv add "tree-sitter-analyzer[all,mcp]"  # Full installation

Top 5 Commands

# 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"
๐Ÿ“‹ View Output Example
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                   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.


๐ŸŒ Supported Languages

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.


๐Ÿ“Š Features Overview

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

๐Ÿ† Quality & Testing

Metric Value
Tests 4,864 passed โœ…
Coverage 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

๐Ÿ› ๏ธ Development

Setup

git clone https://github.com/aimasteracc/tree-sitter-analyzer.git
cd tree-sitter-analyzer
uv sync --extra all --extra mcp

Quality Checks

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.


๐Ÿค Contributing & License

We welcome contributions! See Contributing Guide for development guidelines.

โญ Support

If this project helps you, please give us a โญ on GitHub!

๐Ÿ’ Sponsors

@o93 - Lead Sponsor supporting MCP tool enhancement, test infrastructure, and quality improvements.

๐Ÿ’– Sponsor this project

๐Ÿ“„ License

MIT License - see LICENSE file.


๐Ÿ“š Documentation

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

About

A scalable, multi-language code analysis framework based on Tree-sitter, usable both as a CLI tool and an MCP server.

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 5