Tree Sitter
Configure the server. Args: config_path: Path to YAML config file cache_enabled: Whether to enable parse tree caching max_file_size_mb: Maximum file size in MB log_level: Logging leve
What is Tree Sitter?
Tree Sitter is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to configure the server. args: config_path: path to yaml config file cache_enabled: whether to enable parse tree caching max_file_size_mb: maximum file size in mb log_level: logging leve
Configure the server. Args: config_path: Path to YAML config file cache_enabled: Whether to enable parse tree caching max_file_size_mb: Maximum file size in MB log_level: Logging leve
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- configure
- register_project_tool
- list_projects_tool
- remove_project_tool
- list_languages
Use Cases
Maintainer
Works with
Installation
NPM
npx -y mcp-server-tree-sitterManual Installation
npx -y mcp-server-tree-sitterConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Tree Sitter
The Tree-sitter MCP server brings structural code analysis to AI assistants by parsing source files into abstract syntax trees (ASTs) using the battle-tested tree-sitter library. It exposes tools for registering projects, searching code with tree-sitter queries, extracting symbols like functions and classes, and measuring complexity — all without running the code. Developers use it to give AI models deep, language-aware understanding of large codebases for refactoring, navigation, and dependency analysis.
Prerequisites
- Python 3.9 or higher installed
- pip package manager available
- An MCP client such as Claude Desktop or Claude Code CLI
- The tree-sitter grammar packages for each language you want to analyze (installed automatically or via pip)
Install the package
Install mcp-server-tree-sitter from PyPI using pip.
pip install mcp-server-tree-sitterRegister the server with Claude Desktop (MCP CLI)
Use the MCP CLI to register the server so Claude Desktop can discover and launch it automatically.
mcp install mcp_server_tree_sitter.server:mcp --name "tree_sitter"Configure optional environment variables
Set environment variables to tune logging and cache behaviour. MCP_TS_LOG_LEVEL controls verbosity (DEBUG, INFO, WARNING, ERROR). MCP_TS_CACHE_MAX_SIZE_MB caps the parse-tree cache. MCP_TS_CONFIG_PATH points to a YAML config file for advanced settings.
export MCP_TS_LOG_LEVEL=INFO
export MCP_TS_CACHE_MAX_SIZE_MB=256Add the server to Claude Desktop config manually (alternative)
If you prefer manual configuration, add the server entry to your Claude Desktop config file at ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows).
Register a project inside the MCP session
Once connected, use the register_project_tool to point the server at your codebase. The server will index the directory and make it available for all subsequent analysis tools.
Run tree-sitter queries and extract symbols
Use get_symbols to list functions and classes in a file, or run_query to execute arbitrary tree-sitter S-expression queries across registered projects.
Tree Sitter Examples
Client configuration
Add this block to your Claude Desktop claude_desktop_config.json to launch the tree-sitter MCP server.
{
"mcpServers": {
"tree_sitter": {
"command": "python",
"args": ["-m", "mcp_server_tree_sitter.server"],
"env": {
"MCP_TS_LOG_LEVEL": "INFO",
"MCP_TS_CACHE_MAX_SIZE_MB": "256"
}
}
}
}Prompts to try
After registering a project, ask your AI assistant to explore the codebase structure and run analyses.
- "Register the project at /Users/me/myapp and list all Python files in the src directory."
- "Extract all function names and their signatures from src/api/routes.py."
- "Find every class that inherits from BaseModel in my registered project using a tree-sitter query."
- "Measure the cyclomatic complexity of the functions in utils/helpers.py and highlight the most complex ones."
- "Search for all function calls to 'connect_db' across the entire project."Troubleshooting Tree Sitter
Language grammar not found when analysing a file
Install the tree-sitter grammar for the target language, e.g. `pip install tree-sitter-python` or `pip install tree-sitter-javascript`. The server auto-detects languages by file extension but requires the grammar package to be installed.
Server fails to start: 'mcp_server_tree_sitter module not found'
Ensure the package was installed in the same Python environment the server is launched from. If using virtual environments, activate the correct env or use the full path to the Python binary in your config.
Parse tree cache grows too large and consumes excessive memory
Set MCP_TS_CACHE_MAX_SIZE_MB to a lower value (e.g. 128) in your environment or YAML config file to cap memory usage.
Frequently Asked Questions about Tree Sitter
What is Tree Sitter?
Tree Sitter is a Model Context Protocol (MCP) server that configure the server. args: config_path: path to yaml config file cache_enabled: whether to enable parse tree caching max_file_size_mb: maximum file size in mb log_level: logging leve It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Tree Sitter?
Install via npm with the command: npx -y mcp-server-tree-sitter. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).
Which AI clients work with Tree Sitter?
Tree Sitter works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Tree Sitter free to use?
Yes, Tree Sitter is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.
Tree Sitter Alternatives — Similar Developer Tools Servers
Looking for alternatives to Tree Sitter? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Tree Sitter in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Tree Sitter?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.