MCP Tree-sitter Server is an MCP server that provides structure-aware code analysis capabilities using tree-sitter parsers to language models. It connects local code repositories to AI assistants like Claude Desktop, allowing software engineers and developers to inspect source code without overflowing model context windows. The server parses source code across languages such as Python, JavaScript, TypeScript, Go, Rust, C, C++, and Java through tree-sitter language packs. Instead of loading whole files indiscriminately, the server allows clients to register local projects, inspect directory structures, generate abstract syntax trees, and extract specific symbols such as functions and classes. It also enables structural tree-sitter pattern queries, text searches, and cyclomatic complexity analysis. By caching parse trees in memory and preserving project registrations between calls, the server reduces parse overhead and enables efficient, multi-step code exploration workflows for code reviews, refactoring, and code understanding.
Category: AI Memory & Context
Tags: ast, code analysis, context, parsing, tree-sitter
To install and configure MCP Tree-sitter Server for Claude Desktop: 1. Ensure Python 3.10+ is installed on your system. 2. Install the package using pip: pip install mcp-server-tree-sitter 3. Open your Claude Desktop configuration file: - macOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json - Windows: %APPDATA%\Claude\claude_desktop_config.json 4. Add the server definition inside mcpServers using uvx or python: json { "mcpServers": { "tree_sitter": { "command": "uvx", "args": ["--directory", "/ABSOLUTE/PATH/TO/YOUR/PROJECT", "mcp-server-tree-sitter"] } } } 5. Replace /ABSOLUTE/PATH/TO/YOUR/PROJECT with your actual project path. 6. Restart Claude Desktop to begin using the registered tools.
Part of MCP Servers
You can install MCP Tree-sitter Server using pip by running pip install mcp-server-tree-sitter. Alternatively, you can run it directly using uvx with uvx --directory /path/to/project mcp-server-tree-sitter in your client configuration.
Claude Desktop is the primary reference implementation target documented for the server. It can also be inspected and run using the MCP CLI via direct commands or the MCP Inspector development tool.
The server supports multiple languages via tree-sitter-language-pack, including Python, JavaScript, TypeScript, Go, Rust, C, C++, C#, Swift, Java, Kotlin, Dart, Julia, and APL. Parsers can be loaded on-demand or pre-loaded via configuration.
It provides tools to register projects, list project files, retrieve file content, inspect abstract syntax trees, extract symbols like functions and classes, perform text and Tree-sitter query searches, and analyze code complexity.
Yes. It maintains state in memory, caching parse trees and registered projects between client calls to maximize performance. Caching behavior, size limits, and time-to-live settings can be adjusted through YAML configuration files or environment variables.