# Tree-sitter MCP Server

> Tree-sitter MCP Server is an open-source MCP server for developer tools. Show the Tree-sitter syntax tree of a code snippet to check node kinds and fields. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, Self-hosted
- **Repository:** https://github.com/joowani/tree-sitter-mcp-server
- **MCP Registry name:** io.github.joowani/tree-sitter-mcp-server
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-23

## About

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.

## Features

- **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

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add tree-sitter-mcp-server -- npx -y tree-sitter-mcp-server
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

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

### Claude Desktop (claude_desktop_config.json)

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

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

### Cursor (~/.cursor/mcp.json)

```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.

### VS Code (~/.copilot/mcp-config.json)

```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.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add tree-sitter-mcp-server -- npx -y tree-sitter-mcp-server
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.tree-sitter-mcp-server]
command = "npx"
args = ["-y", "tree-sitter-mcp-server"]
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```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

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```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 (~/.config/devin/mcp_config.json)

```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 (cline_mcp_settings.json)

```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 (Zed settings.json)

```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 (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

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

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```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 (~/.kiro/settings/mcp.json)

```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.

### Other clients (your client's MCP settings (most use this shape))

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

## Tools

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_ast` (name suggests: reads): Return the Tree-sitter syntax tree of a code snippet for a given language

## 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.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Context7](https://ai-powered.com/mcp/context7): Context7 is a freemium MCP server for developer tools.
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): Chrome DevTools MCP is an open-source MCP server for browser automation.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.
- [awesome-mcp-servers](https://ai-powered.com/mcp/awesome-mcp-servers-2): awesome-mcp-servers is an open-source MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/tree-sitter-mcp-server
