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.
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/uvx, then Homebrew, then downloads a prebuilt
from the tool's latest GitHub release. Override the channel with
TS_PACK_LAUNCHER=auto|npx|uvx|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.
1---2name: using-the-mcp-server3description: 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.4---56<!--7AI-RULEZ :: GENERATED FILE — DO NOT EDIT8Content-Hash: blake3:4c8c2a57d4c5fa03c6ff57dee5175b3229dcc0af0338d8e31901473b2d46a5429Source-Hash: blake3:fb473cce01667ed754521c9b257fba33e63f7f525de03fbe8472c74a3ebc2bcd10Schema-Version: v111-->1213# Using the MCP Server1415The `tree-sitter-language-pack` MCP server exposes `ts-pack`'s parsing and16code-intelligence capabilities as MCP tools, so an MCP-compatible client (Claude17Code, Claude Desktop) can parse source, extract structure, and detect languages18directly, with no CLI invocation or glue code.1920## How it runs in this plugin2122The plugin auto-registers the server. Its command is the bundled launcher23`scripts/mcp-launch.sh`, which execs `ts-pack mcp`. On first run the launcher24resolves a `ts-pack` binary: it reuses one already on `PATH` or cached in the25plugin's `bin/`, then tries `npx`/`uvx`, then Homebrew, then downloads a prebuilt26from the tool's latest GitHub release. Override the channel with27`TS_PACK_LAUNCHER=auto|npx|uvx|brew|download`.2829The `mcp` subcommand ships in a recent release of the tool. If an older30`ts-pack` is already on `PATH`, it may not expose `mcp` yet — upgrade the binary31(`brew upgrade`, re-download, or rebuild) to pick it up.3233To run it manually:3435```bash36ts-pack mcp # for Claude Code / Claude Desktop (stdio)37```3839## The tools4041**Parsing and code intelligence:**4243- **parse** — syntax tree from `source`; requires an explicit `language`, with44 optional `format` (`sexp` or `json`). It does not detect language from a path —45 use `detect_language` first if you only have a path.46- **process** — code intelligence: structure, imports, exports, symbols, docstrings, comments, diagnostics, chunks. Use `all` flag to enable all features.47- **detect_language** — identify language by `path` or `content` (those are48 the only two parameters; extension detection is implicit in `path`).4950**Language and cache management:**5152- **list_languages** — available, downloaded, or manifest languages; optional filter by name.53- **info** — show language availability and cache status.54- **download** — prefetch parsers: specific languages, language groups, all, or fresh updates.55- **cache_dir** — return the cache directory path.56- **clean_cache** — remove all cached parsers.5758## Resources5960- `ts-pack://languages` — catalog of all known languages.61- `ts-pack://languages/downloaded` — currently cached languages.62- `ts-pack://language/{name}` — per-language metadata template.6364## Prompt and completions6566- **analyze-code** — code-analysis prompt (args: `language`, optional `focus`).67- **Language-name autocomplete** — available language names in completions.6869## When to prefer MCP over the CLI or SDK7071- **Prefer MCP** inside an agent session: the agent calls parsing directly as a72 tool, with no shell-out and no process management.73- **Prefer the CLI** for one-shot parsing/extraction and shell/CI pipelines.74- **Prefer the SDK** when embedding parsing in application code or running custom75 tree-sitter queries.