A Model Context Protocol (MCP) server that provides code analysis capabilities using Tree-sitter, designed to give Claude intelligent access to codebases with appropriate context management.
For a comprehensive list of all available commands, their current implementation status, and detailed feature matrix, please refer to the FEATURES.md document.
pip install mcp-server-tree-sitter
git clone https://github.com/wrale/mcp-server-tree-sitter.git
cd mcp-server-tree-sitter
pip install -e ".[dev,languages]"
You can make the server available in Claude Desktop either through the MCP CLI or by manually configuring Claude Desktop.
Register the server with Claude Desktop:
mcp install mcp_server_tree_sitter.server:mcp --name "tree_sitter"
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
Create the file if it doesn't exist.
mcpServers
section:{
"mcpServers": {
"tree_sitter": {
"command": "python",
"args": ["-m", "mcp_server_tree_sitter.server"]
}
}
}
mcpServers
section:{
"mcpServers": {
"tree_sitter": {
"command": "uvx",
"args": ["--directory", "/ABSOLUTE/PATH/TO/YOUR/PROJECT", "mcp-server-tree-sitter"]
}
}
}
register_project_tool(path="/path/to/your/project", name="my-project")
List files in the project:
list_files(project="my-project", pattern="**/*.py")
View file content:
get_file(project="my-project", path="src/main.py")
Get the syntax tree:
get_ast(project="my-project", path="src/main.py", max_depth=3)
Extract symbols:
get_symbols(project="my-project", path="src/main.py")
Search for text:
find_text(project="my-project", pattern="function", file_pattern="**/*.py")
Run Tree-sitter queries:
run_query(
project="my-project",
query='(function_definition name: (identifier) @function.name)',
language="python"
)
analyze_complexity(project="my-project", path="src/main.py")
Create a YAML configuration file:
cache:
enabled: true
max_size_mb: 100
ttl_seconds: 300
security:
max_file_size_mb: 5
excluded_dirs:
- .git
- node_modules
- __pycache__
language:
default_max_depth: 5
preferred_languages:
- python
- javascript
log_level: INFO
max_results_default: 100
Load it with:
configure(config_path="/path/to/config.yaml")
MIT
MCP Server for Tree-sitter
tree-sitter mcp code-analysis ast code-search claude coding-assistant ai-assistant claude-ai claude-desktop model-context-protocol model-context-protocol-servers