tree-sitter-analyzer
A scalable, multi-language code analysis framework based on Tree-sitter, usable both as a CLI tool and an MCP server.
claude mcp add --transport stdio aimasteracc-tree-sitter-analyzer uvx --from tree-sitter-analyzer[mcp] tree-sitter-analyzer-mcp \ --env TREE_SITTER_OUTPUT_PATH="path to output directory" \ --env TREE_SITTER_PROJECT_ROOT="path to your project root"
How to use
Tree-sitter Analyzer is a code analysis tool that integrates with MCP to enable AI assistants to work with your codebase. It powers features like language-aware code analysis, structure extraction, and targeted queries across many programming languages. By configuring the MCP server with uvx, you expose a command interface that your AI assistant can call to generate analyses, summaries, or structured data about source files. The included example demonstrates how to point the MCP tool at your project and direct output to a desired location, enabling seamless feedback to the AI assistant for tasks such as code understanding, search, and navigation.
To use the MCP integration, run the provided uvx command via your MCP-enabled assistant configuration. You’ll specify the project root and an output directory through environment variables, allowing the analyzer to read your codebase and write results that the AI can consume. After configuring, restart the AI client and instruct it to set the project root directory when prompted, so subsequent analyses are performed against the correct repository.
How to install
Prerequisites:
- Python 3.10+ (or a compatible Python environment)
- uv (the Universal Verifier/Worker CLI) installed
- Optional: fd and ripgrep for enhanced search features
- Install uv on your system (examples):
- 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 the Tree-sitter Analyzer with MCP support:
uv add "tree-sitter-analyzer[all,mcp]" # Full installation including MCP features
- Verify installation and available commands:
uv run tree-sitter-analyzer --help
- Run the MCP integration example (as part of your MCP config):
- Ensure you have a suitable project root and output path prepared
- Use the MCP config snippet provided in the README to enable the integration
Optional: If you need to install additional dependencies for languages or tooling, follow the project’s docs for language packs and formatting/tools.
Additional notes
Tips and notes:
- Environment variables TREE_SITTER_PROJECT_ROOT and TREE_SITTER_OUTPUT_PATH are placeholders. Replace them with your actual paths in the MCP config or set them in your environment where the MCP runner executes.
- The MCP config uses uvx to launch the analyzer via the MCP protocol; ensure your MCP client supports uvx and that the project root path is accessible by the runtime.
- If you encounter issues with language support, verify that the required language parsers are installed and that your Python environment has the necessary dependencies for tree-sitter integration.
- For best results, keep your project structure stable and avoid moving large directories between analyses without updating the PROJECT_ROOT path.
- This server is configured for a Python-based toolchain; if you migrate to a different runtime, adapt the command and environment settings accordingly.
Related MCP Servers
gpt-researcher
An autonomous agent that conducts deep research on any data using any LLM providers.
serena
A powerful coding agent toolkit providing semantic retrieval and editing capabilities (MCP server & other integrations)
chunkhound
Local first codebase intelligence
spec-coding
Transform feature ideas into production-ready code through systematic Spec-Driven Development 通过系统化的**规格驱动开发**,将功能想法转化为可投入生产的代码
packt-netops-ai-workshop
🔧 Build Intelligent Networks with AI
clangaroo
🦘 Clangaroo: Fast C++ code intelligence for LLMs via MCP