Tree Sitter

v1.0.0Developer Toolsstable

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

ai-assistantastclaudeclaude-aiclaude-desktop
Share:
304
Stars
0
Downloads
0
Weekly
0/5

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

AST parsing and analysis
Code structure understanding
Code search and navigation
wrale

Maintainer

LicenseMIT License
Languagepython
Versionv1.0.0
UpdatedMay 21, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y mcp-server-tree-sitter

Manual Installation

npx -y mcp-server-tree-sitter

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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)
1

Install the package

Install mcp-server-tree-sitter from PyPI using pip.

pip install mcp-server-tree-sitter
2

Register 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"
3

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=256
4

Add 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).

5

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.

6

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.

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.

Quick Config Preview

{ "mcpServers": { "tree-sitter": { "command": "npx", "args": ["-y", "mcp-server-tree-sitter"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides