Tree-sitter MCP Server
Show the Tree-sitter syntax tree of a code snippet to check node kinds and fields
Tree-sitter MCP Server is an open-source MCP server for developer tools. It runs locally on your machine and is started by your AI client.
- Pricing
- Open source
- Platforms
- CLI, Self-hosted
- Runs
- Locally
- What it can do
- Read-only
- Version
- 0.1.1
- Listing updated
Similar MCP servers
Install
Add with the CLI
Run in a terminal
claude mcp add tree-sitter-mcp-server -- npx -y tree-sitter-mcp-serverAdd --scope user to use it in every project, or --scope project to share it in .mcp.json.
Or share it with your project
Add to .mcp.json
{
"mcpServers": {
"tree-sitter-mcp-server": {
"command": "npx",
"args": [
"-y",
"tree-sitter-mcp-server"
]
}
}
}Add to claude_desktop_config.json
{
"mcpServers": {
"tree-sitter-mcp-server": {
"command": "npx",
"args": [
"-y",
"tree-sitter-mcp-server"
]
}
}
}Settings → Developer → Edit Config, then quit and reopen Claude Desktop.
Add to ~/.cursor/mcp.json
{
"mcpServers": {
"tree-sitter-mcp-server": {
"command": "npx",
"args": [
"-y",
"tree-sitter-mcp-server"
]
}
}
}Use .cursor/mcp.json in a project to share it with the project.
Add to ~/.copilot/mcp-config.json
{
"mcpServers": {
"tree-sitter-mcp-server": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"tree-sitter-mcp-server"
]
}
}
}Or put the same entry in .mcp.json at your workspace root to share it.
Add with the CLI
Run in a terminal
codex mcp add tree-sitter-mcp-server -- npx -y tree-sitter-mcp-serverOr add to config.toml
Add to ~/.codex/config.toml
[mcp_servers.tree-sitter-mcp-server]
command = "npx"
args = ["-y", "tree-sitter-mcp-server"]Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"tree-sitter-mcp-server": {
"command": "npx",
"args": [
"-y",
"tree-sitter-mcp-server"
]
}
}
}Gemini CLI and Antigravity
Gemini CLI
Add to ~/.gemini/settings.json
{ "mcpServers": { "tree-sitter-mcp-server": { "command": "npx", "args": [ "-y", "tree-sitter-mcp-server" ] } } }Or run: gemini mcp add -s user tree-sitter-mcp-server npx -- -y tree-sitter-mcp-server
Antigravity
Add to ~/.gemini/config/mcp_config.json
{ "mcpServers": { "tree-sitter-mcp-server": { "command": "npx", "args": [ "-y", "tree-sitter-mcp-server" ] } } }Use .agents/mcp_config.json to add it to one workspace only.
Devin Desktop (formerly Windsurf)
Add to ~/.config/devin/mcp_config.json
{ "mcpServers": { "tree-sitter-mcp-server": { "command": "npx", "args": [ "-y", "tree-sitter-mcp-server" ] } } }On Windows the file is %APPDATA%\devin\mcp_config.json. Use .devin/mcp_config.json to share it with a project.
Cline
Add to cline_mcp_settings.json
{ "mcpServers": { "tree-sitter-mcp-server": { "command": "npx", "args": [ "-y", "tree-sitter-mcp-server" ] } } }Open it from the MCP Servers icon → Configure → Configure MCP Servers.
Zed
Add to Zed settings.json
{ "context_servers": { "tree-sitter-mcp-server": { "command": "npx", "args": [ "-y", "tree-sitter-mcp-server" ] } } }Open it with zed: open settings file. Merge context_servers into the settings you already have.
JetBrains AI Assistant and Junie
AI Assistant
Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add
{ "mcpServers": { "tree-sitter-mcp-server": { "command": "npx", "args": [ "-y", "tree-sitter-mcp-server" ] } } }Junie
Add to ~/.junie/mcp/mcp.json
{ "mcpServers": { "tree-sitter-mcp-server": { "command": "npx", "args": [ "-y", "tree-sitter-mcp-server" ] } } }Use .junie/mcp/mcp.json to share it with a project.
Kiro
Add to ~/.kiro/settings/mcp.json
{ "mcpServers": { "tree-sitter-mcp-server": { "command": "npx", "args": [ "-y", "tree-sitter-mcp-server" ] } } }Use .kiro/settings/mcp.json to add it to one workspace only.
Using several servers? Build one config file with the MCP config generator.
About Tree-sitter MCP Server
Coding agents often guess at Tree-sitter node names when they write queries or tree-walking code. This server has a single tool, get_tree_sitter_ast, that parses a snippet in a chosen language and returns the tree, one named node per line, with field names and zero-based row-column ranges. ERROR and MISSING nodes mark syntax errors, which is useful for debugging grammars.
It supports 25 languages including C, C++, C#, Go, Java, Kotlin, Python, Ruby, Rust, SQL, Swift, TypeScript, Terraform, YAML and Protobuf. Names are case-insensitive and aliases like py, ts and c++ work; JavaScript and JSX use the TypeScript grammars and PHP code must start with <?php.
It installs through npx or cargo, or from a release binary, and runs over stdio.
Tools this server provides (1)
Taken from the project documentation; the running server may differ.
From the tool list in its README, going by the names, all 1 tool only read data.
From the server's own tool labels and tool names; not verified by us.
- get_tree_sitter_astName suggests: reads
- Return the Tree-sitter syntax tree of a code snippet for a given language
What it does
- AST output
- Named nodes with field names and positions.
- Syntax error markers
- ERROR and MISSING nodes show where parsing failed.
- Many languages
- Over two dozen grammars, with common aliases.
- Single tool
- One call returns the whole tree for a snippet.
- Flexible install
- npm, cargo or a release binary.
Good for
- Check node kinds before writing a Tree-sitter query
- Debug code that walks a syntax tree
- Find where a snippet fails to parse
- Compare tree shapes across languages
Pricing
Open source
Tree-sitter MCP Server FAQ
Which languages are supported?
c, cpp, csharp, go, graphql, hcl, java, javascript, json, jsx, kotlin, php, prisma, protobuf, python, ruby, rust, sql, swift, terraform, thrift, toml, tsx, typescript and yaml.
How do I add Tree-sitter MCP Server to Claude Code?
claude mcp add tree-sitter -- npx -y tree-sitter-mcp-server
Are positions zero-based?
Yes, row-column ranges are zero-based.
Any PHP caveat?
PHP code must start with <?php.
Is Tree-sitter MCP Server free?
Yes. Tree-sitter MCP Server is open source, so you can use and self-host it for free.
What are the best alternatives to Tree-sitter MCP Server?
The closest alternatives to Tree-sitter MCP Server are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.
Where this comes from
- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.


