directory_tree
Generate a recursive JSON tree structure of a directory, organizing files and subdirectories into a nested format with 'name', 'type', and 'children' fields. Ideal for visualizing directory hierarchies programmatically.
Instructions
Generate a recursive JSON tree structure of a directory.
Args: path (str): Directory path to generate tree for (absolute or relative to allowed directories)
Returns: str: JSON representation of directory tree with 2-space indentation, or error message if failed
Note: - Path must be within allowed directory roots - Returns nested structure with 'name', 'type', and 'children' fields - Types are either 'directory' or 'file' - Directories include 'children' array, files do not
Input Schema
Name | Required | Description | Default |
---|---|---|---|
path | Yes |