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
.gitignore
: Excludes files and directories based on.gitignore
rules - Exclude 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
It is an MCP server that generates a file tree under a specified directory. It excludes certain files and directories, such as directories starting with .
or conditions in .gitignore
. By incorporating it into Claude, it helps Claude to quickly see the structure of the project and identify the files that Claude should edit.
function
- Gets the file tree under the specified directory in JSON format.
- Exclude files/directories according to
.gitignore
conditions - Represents the directory structure as hierarchical JSON
set up
Prerequisites
- Python 3.10 or later
- uv
install
Claude for Desktop Settings
Add the following to claude_desktop_config.json
:
Claude usage example
Please specify the root directory one level above src. When considering .gitignore
, it is assumed that .gitignore
exists directly under the root directory. It will work if you specify something like /Users/xxx/GitHub/xxx/ のソースツリーを確認してください
It responds as follows:
This allows Claude to quickly see the project structure.
File Exclusions
Directories beginning with .
are automatically excluded. Files and directories that match a pattern in .gitignore
are automatically excluded from the tree. For example, the following .gitignore
configuration is valid:
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
Generates a JSON file tree from a specified directory's 'src' folder, adhering to '.gitignore' rules, allowing for quick project structure review in Claude.
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityProvides tools for collecting and documenting code from directories.Last updated -466514TypeScriptMIT License
- AsecurityAlicenseAqualityAnalyzes source code dependencies across multiple programming languages in the specified directory to identify file relationships, assisting in dependency management and project structure understanding.Last updated -1PythonMIT License
- AsecurityFlicenseAqualityA TypeScript-based server that visualizes project directory structures in Markdown format, automatically documenting file contents with syntax highlighting and supporting customizable exclusion patterns.Last updated -16752TypeScript
- -securityAlicense-qualityA tool that helps rank codebase files by importance (1-10 scale), track file dependencies, and provide summaries, all accessible through a simple JSON-based interface.Last updated -2TypeScriptGPL 3.0