The MCP Source Tree Server generates a hierarchical JSON representation of a directory's file tree while applying intelligent filtering:
Generate File Tree: Creates a JSON-formatted structure of a specified directory
Filter with : Excludes files and directories based on
.gitignorerulesExclude Hidden Items: Automatically ignores directories and files starting with
.(e.g.,.git/)Preserve Hierarchy: Maintains the original directory structure in the output
Respects .gitignore patterns to exclude files and directories according to Git's ignore rules when generating the file tree.
MCP Source Tree Server
指定されたディレクトリ配下のファイルツリーを生成するMCPサーバーです。
.で始まるディレクトリや.gitignore に記載された条件に従って、特定のファイルやディレクトリを除外します。
Claudeに組み込むことで、Claudeがプロジェクトの構造を素早く確認でき、Claudeが編集すべきファイルを特定するのに役立ちます。
機能
指定されたディレクトリ配下のファイルツリーをJSON形式で取得
.gitignoreの条件に従ってファイル/ディレクトリを除外ディレクトリ構造を階層的なJSONで表現
Related MCP server: MCP Source Relation Server
セットアップ
必要条件
Python 3.10以上
uv
インストール
Claude for Desktopでの設定
claude_desktop_config.json に以下の設定を追加してください:
Claudeでの使用例
指示するのはsrcの一つ上のルートディレクトリを指定してください。
.gitignore を考慮する場合、ルートディレクトリ直下に .gitignore が存在することが前提です。
/Users/xxx/GitHub/xxx/ のソースツリーを確認してください のように指示すると動作します
以下のように応答します
これにより、Claudeが素早くプロジェクトの構造を確認できます。
ファイル除外
.で始まるディレクトリは自動的に除外されます。
.gitignore に記載されているパターンに合致するファイルやディレクトリは、ツリーから自動的に除外されます。
例えば、以下のような .gitignore の設定が有効です: