Tree-sitter MCP Server

io.github.joowaniv0.1.0更新於 Oct 2, 2026

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

已驗證STDIO僅桌面Developer Tools

概覽

AI 產生的概覽

讓助理用 Tree-sitter 解析程式碼片段並檢視產生的語法樹,包括節點類型、欄位名稱和位置。

功能
提供一個工具 get_tree_sitter_ast,接收程式碼字串和語言名稱,回傳 Tree-sitter 語法樹,每行一個具名節點,並帶有欄位名稱和從零開始的列欄範圍。ERROR 和 MISSING 節點用來標示語法錯誤。支援多種語言,包括 C、C++、C#、Go、GraphQL、HCL、Java、JavaScript、JSON、JSX、Kotlin、PHP、Prisma、Protobuf、Python、Ruby、Rust、SQL、Swift、Terraform、Thrift、TOML、TSX、TypeScript 和 YAML,名稱不分大小寫,也支援常見別名。
適用情境
適合助理在撰寫 Tree-sitter 查詢或走訪語法樹的程式碼時,用來確認某個程式碼片段確切的節點類型、欄位名稱和位置。它是針對解析器相關開發工作的輕量輔助工具,而不是通用的程式碼分析工具。
執行需求
透過 stdio 在本機執行。npm 套件以 npx 啟動,需要 Node.js;也可以改用 cargo 或從發行頁面安裝二進位檔,並以 tree-sitter-mcp-server 作為指令。未宣告任何帳號、API 金鑰或環境變數。
安裝前請注意
此伺服器會解析傳給它的程式碼片段;若在意,請避免傳送機密或敏感原始碼。未宣告任何身分驗證、憑證、付款或寫入操作。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Tree-sitter MCP Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

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:

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

Codex:

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

Other clients:

json
{  "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.

json
{  "language": "python",  "code": "x = 1"}
text
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)

來源:README.md,提交 d12ee35

工具

0
工具後設資料尚未被收錄。

版本歷史

1
  1. v0.1.0最新Oct 2, 2026