MCP Source Tree Server

by owayo
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Respects .gitignore patterns to exclude files and directories according to Git's ignore rules when generating the file tree.

MCP 源树服务器

这是一个在指定目录下生成文件树的 MCP 服务器。根据以 开头的目录排除特定的文件或目录..gitignore中列出的条件。与 Claude 集成可以让 Claude 快速查看项目结构并帮助他确定要编辑的文件。

功能

  • 以 JSON 格式获取指定目录下的文件树。
  • 根据.gitignore条件排除文件/目录
  • 将目录结构表示为分层 JSON

设置

先决条件

  • Python 3.10 或更高版本
  • 紫外线

安装

# uvのインストール $ curl -LsSf https://astral.sh/uv/install.sh | sh $ cd /path/to/mcp-src-tree # ライブラリのインストール $ uv sync

Claude 用于桌面设置

将以下内容添加到claude_desktop_config.json

{ "mcpServers": { "src-tree": { "command": "uv", "args": [ "--directory", "/path/to/mcp-src-tree", # このプロジェクトディレクトリの絶対パスに書き換えてください "run", "tree.py" ] } } }

Claude 使用示例

请指定 src 上一级的根目录。当考虑.gitignore时,假定.gitignore直接存在于根目录下。 /Users/xxx/GitHub/xxx/ のソースツリーを確認してください,它将会起作用。

其回应如下:

はい、ソースツリーを確認させていただきます。 プロジェクトの構造を確認しました。以下のような構成になっています: src/ └── xxxx/ ├── __init__.py ├── converter.py ├── html_converter.py ├── image_processor.py ├── toc_analyzer.py └── utils.py

这使得 Claude 能够快速了解项目结构。

文件排除

以 开头的目录.将被自动排除。与.gitignore中的模式匹配的文件和目录将自动从树中排除。例如,以下.gitignore配置是有效的:

__pycache__/ node_modules/ *.log

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

从指定目录的“src”文件夹生成 JSON 文件树,遵守“.gitignore”规则,以便在 Claude 中快速审查项目结构。

  1. 機能
    1. セットアップ
      1. 必要条件
      2. インストール
    2. Claude for Desktopでの設定
      1. Claudeでの使用例
        1. ファイル除外
          ID: 1igr60piqh