Labsco
MCP SERVER

MCP Tree-sitter Server

by wrale

Explore a codebase at the level you need — file tree, AST, symbols or a tree-sitter query — without flooding the context window.

Code Intelligence & Repository Indexing
Summary
Depth is a parameter, which is how it stays inside a context window.

Asking for an AST with max_depth set, or symbols rather than source, is the difference between a useful answer and a dumped file. The query-building tools are the other half: templates and adapt_query mean the assistant can construct a tree-sitter query for a language it has not seen a pattern for, rather than falling back to text search.

What it is

A code analysis server built on tree-sitter. You register a project once, then read it at whatever granularity the question needs.

What you get
  • Project management — register_project_tool, list_projects_tool and remove_project_tool, with registrations persisting for the server's lifetime
  • Files — list_files with a glob pattern, get_file and get_file_metadata
  • AST — get_ast with a max_depth, and get_node_at_position
  • Search — find_text with a file pattern, and run_query for real tree-sitter queries against a language
  • Symbols — get_symbols and find_usage
  • Project analysis — analyze_project, get_dependencies and analyze_complexity
  • Query building — get_query_template_tool, list_query_templates_tool, build_query, adapt_query and get_node_types
  • find_similar_code, clear_cache and diagnose_config
  • Resources under project:// for files, patterns, file content, line ranges and ASTs, plus prompts for code review, explanation and project overview
  • Many languages through tree-sitter-language-pack, including Python, JavaScript, TypeScript, Go, Rust, C, C++, C#, Swift, Java, Kotlin, Dart, Julia and APL
Requirements

Python 3.10+ and pip install mcp-server-tree-sitter. Register it with Claude Desktop through the MCP CLI, or point the client at the module — uvx works for the released package. A YAML config controls caching, security limits such as max_file_size_mb and excluded_dirs, AST depth, and preferred_languages to pre-load parsers at startup; MCP_TS_ environment variables override it.

Setup effort

One command — pip install mcp-server-tree-sitter