mcpField
C
Code To Tree

Code To Tree

ローカル
github.com/micl2e2開発ツール8933 週間前に更新

Code To Tree について

Code To Tree は、tree-sitter を用いてソースコードを AST(抽象構文木)に変換する単一バイナリの MCP サーバーです。複数言語のコード構造を正確に把握したい LLM 向けに設計されています。

主な機能

  1. 01ソースコードから AST への変換
  2. 02tree-sitter による構文解析
  3. 03C、C++、Rust、Ruby、Go、Java、Python に対応
  4. 04依存関係の少ない単独バイナリ

活用シーン

  1. 01LLM によるファイルの構文構造の確認
  2. 02リファクタリング前の関数やクラスの階層確認
  3. 03複数言語の構文木の比較

MCP 対応

単独バイナリとして動作する MCP サーバーであり、ソースコードから AST への変換機能を MCP クライアントに提供します。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

インストール方法は未掲載です

このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。

リポジトリ

ツール

ツール一覧はまだ取得されていません

ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。

詳細

目次

MCP サーバー:code-to-tree

code-to-tree サーバーの目標は次のとおりです。

  1. 言語を問わず、LLM がソースコードを AST(抽象構文木)に正確に変換できるようにします。
  2. MCP クライアントが必要とするものをすべて、スタンドアロンバイナリ 1 つにまとめます。

この目標から、次のことが導かれます。

  1. 基盤となる構文パーサーには、十分な汎用性が必要です。ここでは tree-sitter を採用し、対応言語は C、C++、Rust、Ruby、Go、Java、Python です。
  2. サーバーはすべての機能を自身に内包し、エンドユーザーのマシンに必要なソフトウェア依存関係を最小限に抑える必要があります。ここでは mcpc を採用しています。

スクリーンショット:

README の画像README の画像

上記のスクリーンショットは、q.md に記載された質問をしたときに取得したものです。

(重要な注意事項:LLM には、同じ質問に対して同一の結果を生成する責任はありません。回答のスタイルや内容は大きく異なる場合があります。ここに掲載されているスクリーンショットや質問は、あくまで参考用です)

code-to-tree MCP サーバー

code-to-tree の使用

まず、マシンに code-to-tree 実行ファイル(Windows の場合は code-to-tree.exe、macOS の場合は code-to-tree)が必要です。GitHub のリリースページからダウンロードするか、自分でビルドしてください。ダウンロードしたら、MCP クライアントにインストールするよう設定します。詳しくは「MCP クライアントの設定」のセクションを確認してください。

MCP クライアントの設定

ここでは Claude を例に説明します。

Windows

Claude の設定ファイル (C:\Users\YOUR_NAME\AppData\Roaming\Claude\claude_desktop_config.json)で、 code-to-tree.exe の場所を指定します。

{
    "mcpServers": {
	    "code-to-tree": { "command": "C:\\path\\to\\code-to-tree.exe" }
    }
}

macOS

Claude の設定ファイル (~/Library/Application Support/Claude/claude_desktop_config.json) で、code-to-tree の場所を指定します。

{
    "mcpServers": {
	    "code-to-tree": { "command": "/path/to/code-to-tree" }
    }
}

ビルド(Windows)

1. 環境を準備する

  1. MSYS2 をダウンロードしてインストールします。
  2. 「MSYS2 MINGW64」アプリケーションを開きます。
  3. pacman -S make gcc git を実行します。

2. tree-sitter ライブラリを準備する

ここでは tree-sitter と関連するすべての文法をコンパイルしてインストールします。

以下をクローンします。

git clone https://github.com/tree-sitter/tree-sitter

git clone https://github.com/tree-sitter/tree-sitter-c

git clone https://github.com/tree-sitter/tree-sitter-cpp

git clone https://github.com/tree-sitter/tree-sitter-rust

git clone https://github.com/tree-sitter/tree-sitter-ruby

git clone https://github.com/tree-sitter/tree-sitter-go

git clone https://github.com/tree-sitter/tree-sitter-java

コンパイルしてインストールします。

cd tree-sitter && OS=1 make install

cd tree-sitter-c && OS=1 make install

cd tree-sitter-cpp && OS=1 make install

cd tree-sitter-rust && OS=1 make install

cd tree-sitter-ruby && OS=1 make install

cd tree-sitter-go && OS=1 make install

cd tree-sitter-java && OS=1 make install

3. code-to-tree をビルドする

mcpc をインストールします:

git clone https://github.com/micl2e2/mcpc
cd mcpc && make install

code-to-tree をコンパイルします:

cd mcpc/example/code-to-tree

CFLAGS="-I/usr/local/include -L/usr/local/lib" make

# バイナリを確認します
file code-to-tree.exe

# バイナリの場所を控えておきます
pwd
# 出力は次のとおりとします:/c/path/to/code-to-tree.exe

ビルド(macOS)

1. 環境を準備する

  1. Xcode Command Line Tools

2. tree-sitter ライブラリを準備する

ここでは、tree-sitter と関連するすべての文法をコンパイルしてインストールします。

クローンします:

git clone https://github.com/tree-sitter/tree-sitter

git clone https://github.com/tree-sitter/tree-sitter-c

git clone https://github.com/tree-sitter/tree-sitter-cpp

git clone https://github.com/tree-sitter/tree-sitter-rust

git clone https://github.com/tree-sitter/tree-sitter-ruby

git clone https://github.com/tree-sitter/tree-sitter-go

git clone https://github.com/tree-sitter/tree-sitter-java

コンパイルしてインストールします:

cd tree-sitter && make install

cd tree-sitter-c && make install

cd tree-sitter-cpp && make install

cd tree-sitter-rust && make install

cd tree-sitter-ruby && make install

cd tree-sitter-go && make install

cd tree-sitter-java && make install

3. code-to-tree をビルドする

mcpc をインストールします:

git clone https://github.com/micl2e2/mcpc
cd mcpc && make install

code-to-tree をコンパイルします:

cd mcpc/example/code-to-tree

make

# バイナリを確認します
file ./code-to-tree

# バイナリの場所を控えておきます
pwd
# 出力は次のとおりとします:/path/to/code-to-tree

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。