AGENT SKILL

tree-sitter MCP 服务器使用

tree-sitter-language-pack-using-the-mcp-server

当用户需要通过 tree-sitter-language-pack MCP 服务器的工具(而非调用 ts-pack CLI 命令行)来解析源代码、提取代码结构或检测语言时使用。涵盖工具接口、自动安装启动器,以及 MCP 在何种情况下优于 CLI 或 SDK。

使用场景开发参考
License 许可
MIT
最近更新
2026-11-15
Stars
★ 485
Forks
71

01 前言 Front Matter

name
tree-sitter-language-pack-using-the-mcp-server
description
Use when parsing source, extracting code structure, or detecting a language through the tree-sitter-language-pack MCP server's tools, rather than shelling out to the ts-pack CLI. Covers the tool surface, the auto-installing launcher, and when MCP beats the CLI or SDK.

02 资源文件 1

03 SKILL.md 正文

<!-- AI-RULEZ :: GENERATED FILE — DO NOT EDIT Content-Hash: blake3:32a9429c4f5c314cfb1deb3eca4cab52f4c96283e07d68ecf017e925486e72ac Source-Hash: blake3:fbed630db85ed02cff8e3bc8c836d453724480351ecb0896122f193a21670041 Schema-Version: v1 -->

Using the MCP Server

The tree-sitter-language-pack MCP server exposes ts-pack's parsing and code-intelligence capabilities as MCP tools, so an MCP-compatible client (Claude Code, Claude Desktop) can parse source, extract structure, and detect languages directly, with no CLI invocation or glue code.

Standalone skill installation

Installing this skill alone does not register an MCP server or include the plugin launcher. Install the CLI (for example, brew install xberg-io/tap/ts-pack), then configure your MCP client with ts-pack mcp as its stdio command. The full product plugin supplies registration where the runtime supports MCP.

How it runs in this plugin

The plugin auto-registers the server. Its command is the bundled launcher scripts/mcp-launch.sh, which execs ts-pack mcp. On first run the launcher resolves a ts-pack binary: it reuses one already on PATH or cached in the plugin's bin/, then tries npx, then Homebrew, then downloads a prebuilt from the tool's latest GitHub release. Override the channel with TS_PACK_LAUNCHER=auto|npx|brew|download.

The mcp subcommand ships in a recent release of the tool. If an older ts-pack is already on PATH, it may not expose mcp yet — upgrade the binary (brew upgrade, re-download, or rebuild) to pick it up.

To run it manually:

ts-pack mcp        # for Claude Code / Claude Desktop (stdio)

The tools

Parsing and code intelligence:

  • parse — syntax tree from source; requires an explicit language, with optional format (sexp or json). It does not detect language from a path — use detect_language first if you only have a path.
  • process — code intelligence: structure, imports, exports, symbols, docstrings, comments, diagnostics, chunks. Use all flag to enable all features.
  • detect_language — identify language by path or content (those are the only two parameters; extension detection is implicit in path).

Language and cache management:

  • list_languages — available, downloaded, or manifest languages; optional filter by name.
  • info — show language availability and cache status.
  • download — prefetch parsers: specific languages, language groups, all, or fresh updates.
  • cache_dir — return the cache directory path.
  • clean_cache — remove all cached parsers.

Resources

  • ts-pack://languages — catalog of all known languages.
  • ts-pack://languages/downloaded — currently cached languages.
  • ts-pack://language/{name} — per-language metadata template.

Prompt and completions

  • analyze-code — code-analysis prompt (args: language, optional focus).
  • Language-name autocomplete — available language names in completions.

When to prefer MCP over the CLI or SDK

  • Prefer MCP inside an agent session: the agent calls parsing directly as a tool, with no shell-out and no process management.
  • Prefer the CLI for one-shot parsing/extraction and shell/CI pipelines.
  • Prefer the SDK when embedding parsing in application code or running custom tree-sitter queries.

04 同仓库更多 Skills

xberg-io
xberg-io/tree-sitter-language-pack

tree-sitter 代码智能解析

tree-sitter-language-pack

使用 tree-sitter 语法从 371 种编程语言中解析并提取代码智能信息。适用于编写解析源代码、提取结构/导入/导出/符号/文档字符串/注释、检测语言、运行语法诊断或为大模型(LLM)生成语法感知分块的代码——支持 Rust、Python、Node.js/TypeScript 或 ts-pack CLI。涵盖安装、CLI 接口、SDK 接口以及解析器缓存管理。

软件开发工程师代码解析与结构分析
★ 485
xberg-io
xberg-io/tree-sitter-language-pack

tree-sitter MCP 服务使用

tree-sitter-language-pack-using-the-mcp-server

当需要通过 tree-sitter-language-pack 的 MCP 服务器工具来解析源代码、提取代码结构或检测语言(而非调用 ts-pack CLI)时使用。涵盖工具接口、自动安装启动器,以及 MCP 相较于 CLI 或 SDK 的优势场景。

软件开发工程师代码解析与结构分析
★ 485
xberg-io
xberg-io/tree-sitter-language-pack

源代码语法树解析

tree-sitter-language-pack-parsing-source

当用户需要为源文件生成 tree-sitter 语法树时使用——以 s-表达式转储或 JSON 树的形式呈现。涵盖 `ts-pack parse`、语言自动检测与 `--language` 的对比、标准输入(stdin)输入以及读取 `has_errors`。

软件开发工程师代码解析与结构分析
★ 485
xberg-io
xberg-io/tree-sitter-language-pack

解析器缓存管理

tree-sitter-language-pack-managing-parsers

当用户需要管理 tree-sitter 解析器缓存时使用——为离线或 CI 运行预取解析器、列出已下载内容、检查某种语言、查找缓存目录或清理缓存。涵盖 `ts-pack download`、`list`、`info`、`cache-dir`、`clean` 和 `init`。

软件开发工程师开发环境与工具链管理
★ 485
xberg-io
xberg-io/tree-sitter-language-pack

代码结构提取

tree-sitter-language-pack-extracting-code-structure

当用户需要从源文件获取结构化代码元数据时使用——包括函数、类、导入、导出、符号、文档字符串、注释或语法诊断。涵盖 `ts-pack process` 的功能开关、JSON 结果结构以及默认功能集。

软件开发工程师代码解析与结构分析
★ 485
xberg-io
xberg-io/tree-sitter-language-pack

编程语言检测

tree-sitter-language-pack-detecting-languages

当用户想知道某个文件或代码片段属于哪种编程语言时使用。涵盖 `ts-pack parse`/`process` 中的隐式检测、通过 `ts-pack list`/`info` 确认是否支持某种语言,以及用于路径、扩展名和原始内容的 SDK 检测函数。

软件开发工程师代码解析与结构分析
★ 485