Directory Tree
directory_treeReturns a recursive JSON tree of files and directories within allowed paths, with optional depth limits and exclusion patterns for inspecting project structure.
Instructions
Get a recursive tree view of files and directories as a JSON structure. Each entry includes 'name', 'type' (file/directory), and 'children' for directories. Files have no children array, while directories always have a children array (which may be empty), except at the last level when 'depth' limits the tree: those directories are not read and have no children array. The output is formatted with 2-space indentation for readability. Only works within allowed directories.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>"
},
"name": "directory_tree"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The directory at the root of the tree. Absolute, or relative to an allowed directory; it must resolve inside the allowed directories. | |
| depth | No | How many levels to descend: 1 lists only the entries directly in path. Directories at the last level have no children array. Omit for the whole tree. | |
| excludePatterns | No | Patterns for entries to leave out, with their contents, matched against each entry's path relative to path. A pattern with no '*' matches that name at any depth ('node_modules' leaves out every node_modules directory); a pattern with '*' is a glob matched as written, and one ending in '/**' also leaves out the directory it names. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes |