Tree-sitter MCP Server

Parse code into Tree-sitter ASTs to see node kinds, field names, and positions

OtherRustv0.1.0

Tree-sitter MCP Server

An MCP server that shows coding agents the Tree-sitter syntax tree of a code snippet, so they can check node kinds, field names, and positions before writing Tree-sitter queries or code that walks a syntax tree.

Installation

Claude Code:

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

Codex:

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

Other clients:

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

npx needs Node.js. Without it, install the binary with cargo install --locked tree-sitter-mcp-server or download it from the releases, and use tree-sitter-mcp-server as the command.

Clients that browse the MCP Registry, such as VS Code, can also install it from there.

mcp-name: io.github.joowani/tree-sitter-mcp-server

Supported Languages

c, cpp, csharp, go, graphql, hcl, java, javascript, json, jsx, kotlin, php, prisma, protobuf, python, ruby, rust, sql, swift, terraform, thrift, toml, tsx, typescript, yaml

Names are case-insensitive, and common aliases such as c++, c#, py, and ts also work. javascript and jsx use the TypeScript and TSX grammars, and terraform uses the HCL grammar. PHP code must start with <?php.

Tool

get_tree_sitter_ast returns the syntax tree of code in language, one named node per line, with field names and zero-based (row-column) ranges. ERROR and MISSING nodes mark syntax errors.

{
  "language": "python",
  "code": "x = 1"
}
module (0-0) - (0-5)
  expression_statement (0-0) - (0-5)
    assignment (0-0) - (0-5)
      left: identifier (0-0) - (0-1)
      right: integer (0-4) - (0-5)

Installation

Source-derived launch command. Check the maintainer’s required arguments and credentials before running:

bash
npx -y tree-sitter-mcp-server

Set up in your AI client

Merge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.

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

Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the client’s tool list, then try a read-only example from its documentation.

Claude Desktop setup reference

Package

tree-sitter-mcp-servernpm

Compatible MCP Clients

Tree-sitter MCP Server works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.

  • Claude Desktop~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.
  • Cursor~/.cursor/mcp.jsonRestart Cursor for changes to take effect.
  • VS Code.vscode/mcp.jsonReload VS Code window for changes to take effect.
  • Windsurf~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect.
  • Claude Code.mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.

Learn More