What Tree-sitter MCP Server MCP server does
Tree-sitter MCP Server MCP server lets an MCP-compatible coding agent inspect the Tree-sitter syntax tree for a code snippet. The result presents one named node per line, showing the node kind, its position, and any grammar field associated with a child node. This makes grammar structure visible without manually running a parser or reading a language grammar first.
The output uses zero-based row-column ranges. For example, an assignment can expose separate nodes for its left identifier and right-hand value, while nested expressions show their parent-child relationships. Nodes named ERROR or MISSING identify syntax problems reported by Tree-sitter.
It belongs in the Developer Tools category and is useful when an agent needs to construct a Tree-sitter query, identify the correct node or field name, or write code that walks an AST.
How it works
The server provides the get_tree_sitter_ast tool. A request contains two values:
language: the language name or a supported alias
code: the source snippet to parse
The response is formatted as an indented tree. Supported languages include C, C++, C#, Go, GraphQL, HCL, Java, JavaScript, JSON, JSX, Kotlin, PHP, Prisma, Protocol Buffers, Python, Ruby, Rust, SQL, Swift, Terraform, Thrift, TOML, TSX, TypeScript, and YAML. Language names are case-insensitive. Common aliases include c++, c#, py, and ts.
JavaScript and JSX use the TypeScript and TSX grammars respectively. Terraform uses the HCL grammar. PHP snippets must begin with <?php for parsing to work as expected.
Setup and configuration
With Node.js installed, configure the server as an MCP command using npx:
{
"mcpServers": {
"tree-sitter": {
"command": "npx",
"args": ["-y", "tree-sitter-mcp-server"]
}
}
}
Claude Code and Codex also provide dedicated commands using the same package invocation. Clients that browse the MCP Registry, including VS Code, can install it from the registry. If Node.js is unavailable, install the executable with Cargo using cargo install --locked tree-sitter-mcp-server, or download a release binary and use tree-sitter-mcp-server as the command.
Tools and capabilities
The single exposed tool, get_tree_sitter_ast, is focused on syntax-tree inspection rather than file operations or source-code modification. It returns named nodes, grammar field names, and ranges for the supplied snippet. This output can help verify assumptions before an agent writes Tree-sitter query patterns or AST traversal logic.
Limitations and notes
Tree-sitter MCP Server MCP server parses the code supplied in the request; the provided material does not describe repository browsing, file editing, diagnostics beyond parser error nodes, or additional tools. Language coverage is limited to the listed grammars and aliases. PHP requires its opening tag, and syntax errors may appear as ERROR or MISSING nodes in the returned tree.