listdir
List directory contents with pagination, filtering by type or name, and optional tree view to quickly explore projects.
Instructions
Lists directory contents with bounded, pageable output. Default: flat listing, max_depth=3, max_entries=500. When has_more=true, pass next_cursor as cursor to fetch the next page. Filter by type with directories_only or files_only, and by entry-name glob with name_pattern (single) or include (multiple OR patterns, e.g. ["A*", "*.go"]). Use counts_only=true for counts without names, flat=false for a visual tree, and relative_paths=true to save tokens. Skips hidden entries and common build/vendor directories during recursion.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| flat | No | Flat listing without tree connectors (one path per line). Default: true | |
| path | No | Directory to list. Relative paths use the configured workspace or MCP client root | |
| cursor | No | Opaque continuation cursor returned by a previous listdir call | |
| include | No | Additional entry-name glob patterns. An entry is included when any pattern matches | |
| file_path | No | Alias for path | |
| max_depth | No | Maximum depth for traversal. Default: 3 | |
| files_only | No | Return files only: true or false. Default: false | |
| counts_only | No | Return matching directory/file counts without listing names: true or false. Default: false | |
| max_entries | No | Maximum entries to return per page. Default: 500, maximum: 10000 | |
| name_pattern | No | Glob matched against each entry name, for example A* or *.go | |
| relative_paths | No | Show paths relative to the root. Saves tokens: true or false. Default: false | |
| directories_only | No | Return directories only while still traversing them: true or false. Default: false |