Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
flatNoFlat listing without tree connectors (one path per line). Default: true
pathNoDirectory to list. Relative paths use the configured workspace or MCP client root
cursorNoOpaque continuation cursor returned by a previous listdir call
includeNoAdditional entry-name glob patterns. An entry is included when any pattern matches
file_pathNoAlias for path
max_depthNoMaximum depth for traversal. Default: 3
files_onlyNoReturn files only: true or false. Default: false
counts_onlyNoReturn matching directory/file counts without listing names: true or false. Default: false
max_entriesNoMaximum entries to return per page. Default: 500, maximum: 10000
name_patternNoGlob matched against each entry name, for example A* or *.go
relative_pathsNoShow paths relative to the root. Saves tokens: true or false. Default: false
directories_onlyNoReturn directories only while still traversing them: true or false. Default: false

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed12 schema fields changedv0.9.5
    • addedInput schema / properties / counts_only
      Added value: +{
      +  "description": "Return matching directory/file counts without listing names: true or false. Default: false",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / cursor
      Added value: +{
      +  "description": "Opaque continuation cursor returned by a previous listdir call",
      +  "type": "string"
      +}
    • addedInput schema / properties / directories_only
      Added value: +{
      +  "description": "Return directories only while still traversing them: true or false. Default: false",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / files_only
      Added value: +{
      +  "description": "Return files only: true or false. Default: false",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / include
      Added value: +{
      +  "description": "Additional entry-name glob patterns. An entry is included when any pattern matches",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": [
      +    "null",
      +    "array"
      +  ]
      +}
    • changedInput schema / properties / max_depth / description
      Previous value: -"Maximum depth for tree traversal. Default: 3"New value: +"Maximum depth for traversal. Default: 3"
    • addedInput schema / properties / max_depth / type
      Added value: +"integer"
    • addedInput schema / properties / max_entries
      Added value: +{
      +  "description": "Maximum entries to return per page. Default: 500, maximum: 10000",
      +  "type": "integer"
      +}
    • addedInput schema / properties / name_pattern
      Added value: +{
      +  "description": "Glob matched against each entry name, for example A* or *.go",
      +  "type": "string"
      +}
    • changedInput schema / properties / path / description
      Previous value: -"Absolute path to the directory to list"New value: +"Directory to list. Relative paths use the configured workspace or MCP client root"
    • changedInput schema / properties / relative_paths / description
      Previous value: -"Show the root as '.' instead of the full absolute path. Saves tokens in output: true or false. Default: false"New value: +"Show paths relative to the root. Saves tokens: true or false. Default: false"
    • addedInput schema / properties / relative_paths / type
      Added value: +"boolean"
  2. Addedv0.8.7
  3. Removed
  4. Changed1 schema field changedv0.7.12
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": false,
      -  "properties": {
      -    "total_dirs": {
      -      "type": "integer"
      -    },
      -    "total_files": {
      -      "type": "integer"
      -    },
      -    "tree": {
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "tree",
      -    "total_files",
      -    "total_dirs"
      -  ],
      -  "type": "object"
      -}New value: +null
  5. Changed1 schema field changedv0.6.2
    • addedInput schema / properties / flat
      Added value: +{
      +  "description": "Flat listing without tree connectors (one path per line). Default: true",
      +  "type": [
      +    "null",
      +    "boolean"
      +  ]
      +}
  6. First observedv0.4.2

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does a good job: it discloses pagination mechanics, skip behavior for hidden/build/vendor entries, the flat/tree distinction, counting mode, and token-saving relative paths. It does not describe the exact response fields, but it mentions has_more and next_cursor sufficient to drive pagination.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Each sentence carries a distinct responsibility: definition, defaults, pagination, filtering, output modes, skipped entries. There is no filler or repetition, and key information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers defaults, pagination, filtering, output modes, and behavioral exclusions, which is a solid level of context. Since there is no output schema, the only minor gap is omitted return record shape, but the provided behavior is enough for a capable agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds relationship semantics beyond the schema: pagination binds has_ more to the cursor parameter, name_pattern versus include as single/multi OR patterns, and counts_only relative_paths as output modifiers. These are not obvious from names alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool 'lists directory contents' and immediately adds the defining scope: bounded, pageable output. This is a specific verb plus resource and distinguishes the tool from siblings like read, write, and grep, even before opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives practical usage guidance: paginate with cursor when has_more=true, filter with directories_only/files_only, and use counts_only or relative_paths for optimization. It does not explicitly tell an agent when to prefer listdir over sibling tools like glob, but the tool's 'list directory contents' purpose implies the context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/knewstimek/agent-tool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server