directory_tree
Generate and visualize a recursive directory structure with customizable depth, file inclusion, and pattern filtering. Supports text or JSON output for clear file hierarchy representation.
Instructions
Get a recursive tree view of files and directories.
Args:
path: Root directory
max_depth: Maximum recursion depth
include_files: Whether to include files (not just directories)
pattern: Optional glob pattern to filter entries
exclude_patterns: Optional patterns to exclude
format: Output format ('text' or 'json')
ctx: MCP context
Returns:
Formatted directory tree
Input Schema
Name | Required | Description | Default |
---|---|---|---|
exclude_patterns | No | ||
format | No | text | |
include_files | No | ||
max_depth | No | ||
path | Yes | ||
pattern | No |
Input Schema (JSON Schema)
{
"properties": {
"exclude_patterns": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Exclude Patterns"
},
"format": {
"default": "text",
"title": "Format",
"type": "string"
},
"include_files": {
"default": true,
"title": "Include Files",
"type": "boolean"
},
"max_depth": {
"default": 3,
"title": "Max Depth",
"type": "integer"
},
"path": {
"title": "Path",
"type": "string"
},
"pattern": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Pattern"
}
},
"required": [
"path"
],
"title": "directory_treeArguments",
"type": "object"
}