
pwno-io/treesitter-mcp
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
植木機用MCPサーバー
概要
ツリー・シッターを使ってコードを解析・解析するMCPサーバとCLI - ファイルをパースしてASTを取得 - 関数と変数の抽出 - コールグラフのビルド - 関数/変数が使用される場所を見つける - カスタムを実行します ツリー・シッターの問い合わせ - リストのインポート/インクルード - 特定の行/列範囲のソースコードの抽出 - スタンドアローンCLIまたはClaudeデスクトップ用のMCPサーバーとして使用 これは、両方のツリーッタmcpとts-cliエントリポイントをインストールします。 Claude デスクトップまたは他の MCP クライアントの使用のため: 設定方法については、docs/MCP USAGE.md を参照してください。 端末から直接解析を実行します。 --output-file を使用して、stdout ではなく JSON ファイルに結果を記述します。 または URL クエリ パラメータ経由で: [http://127.0.0.1:8000?tools=treesitter_analyze_file,treesitter_get_ast
概要(AI 翻訳)
ツリー・シッターを使ってコードを解析・解析するMCPサーバとCLI
それが何をするか
- ファイルをパースしてASTを取得
- 関数と変数の抽出
- コールグラフの構築
- 関数/変数が使用される場所を見つけて下さい
- カスタムツリーシッターのクエリを実行
- リストの輸入/含まれている
- 特定のライン/コラムの範囲のための源コードを抽出して下さい
- スタンドアローンCLIまたはClaudeデスクトップ用のMCPサーバーとして使用
インストール
Python 3.10+ が必要です。
treesitter-mcpとts-cliの両方のエントリポイントをインストールします。
インストールせずに実行するか:
ランニング
##MCP サーバーとして (デフォルト) Claude デスクトップまたは他の MCP クライアントの使用のため:
設定方法の[docs/MCP_USAGE.mdを参照してください。
スタンドアローン CLI (ts-cli)
端末から直接解析を実行します。
stdout ではなく JSON ファイルに結果を書き込むには、[--output-file を使用します。
HTTP モード
テストか手動使用のため:
制限ツール
[--tools で特定のツールを公開するだけ:
または URL クエリ パラメータ経由で: [http://127.0.0.1:8000?tools=treesitter_analyze_file,treesitter_get_ast
利用できる用具:
- [
treesitter_analyze_file- 基本解析 - [
treesitter_get_ast- フルAST - [
treesitter_get_call_graph- 関数呼び出し
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
Tree-sitter MCP Server & CLI
An MCP server and CLI that uses Tree-sitter to parse and analyze code.
What it does
- Parse files and get their AST
- Extract functions and variables
- Build call graphs
- Find where functions/variables are used
- Run custom Tree-sitter queries
- List imports/includes
- Extract source code for specific line/column ranges
- Use as a standalone CLI or as an MCP server for Claude Desktop
Install
Requires Python 3.10+.
# Install directly
uv pip install treesitter-mcp
# Or install a specific version
uv pip install treesitter-mcp==2.1
# Or clone and install
git clone https://github.com/pwno-io/treesitter-mcp.git
cd treesitter-mcp
uv pip install -e .
This installs both treesitter-mcp and ts-cli entry points.
Or run without installing:
uvx treesitter-mcp
Running
As an MCP server (default)
For use with Claude Desktop or other MCP clients:
treesitter-mcp
See docs/MCP_USAGE.md for how to configure.
Standalone CLI (ts-cli)
Run analysis directly from the terminal:
ts-cli path/to/file.py
ts-cli path/to/file.py --ast --max-depth 2
ts-cli path/to/file.py --find-function main --include-source
ts-cli --supported-languages
Use --output-file to write results to JSON files instead of stdout.
HTTP mode
For testing or manual use:
treesitter-mcp --http --port 8000 --host 127.0.0.1
Limiting tools
Only expose certain tools with --tools:
treesitter-mcp --http --port 8000 --tools treesitter_analyze_file,treesitter_get_ast
Or via URL query param: http://127.0.0.1:8000?tools=treesitter_analyze_file,treesitter_get_ast
Tools available:
treesitter_analyze_file- Basic analysistreesitter_get_ast- Full ASTtreesitter_get_call_graph- Function callstreesitter_find_function- Find function definitionstreesitter_find_variable- Find variablestreesitter_get_source_for_range- Extract source code for a rangetreesitter_get_supported_languages- What’s supportedtreesitter_get_node_at_point- AST node at a line/columntreesitter_get_node_for_range- AST node for a rangetreesitter_cursor_walk- Walk tree with contexttreesitter_run_query- Custom Tree-sitter queriestreesitter_find_usage- Find symbol usagestreesitter_get_dependencies- Extract imports/includes
If you don’t specify --tools, everything is exposed.
Writing output to file
All tools support an optional output_file parameter. When provided, the tool
writes its result directly to the specified file (as pretty-printed JSON) instead
of returning it. This is useful for large outputs like ASTs that could cause
context overload in agents.
Example:
# Returns result to file, minimal response to agent
treesitter_get_ast(file_path="large_file.py", output_file="~/output/ast.json")
# Returns: {"status": "written", "output_file": "/home/user/output/ast.json", "bytes_written": 123456}
インストール
uvx treesitter-mcp