Skip to main content
List files and directories in a container image without spawning a VM.

Overview

list_files provides instant filesystem inspection without the overhead of starting a container. Use it to explore image contents, verify file existence, and check permissions before running commands.

Parameters

ParameterTypeRequiredDefaultDescription
imagestringYes-Image UUID or tag:name
pathstringNo/Directory path to list

Returns

FieldTypeDescription
pathstringNormalized path that was listed
countintegerNumber of entries in listing
filesarrayList of file entries

File Entry Fields

FieldTypeDescription
namestringFile or directory name
pathstringFull path within image
typestringfile, directory, or symlink
sizeintegerSize in bytes
modestringOctal permission mode (e.g., 0o755)
targetstringSymlink target (only for symlinks)

Cost

Free - No VM spawned. Reads directly from image filesystem.

Examples

List Root Directory

{
  "tool": "list_files",
  "args": {
    "image": "abc123-def456",
    "path": "/"
  }
}
Response:
{
  "path": "/",
  "count": 15,
  "files": [
    {"name": "bin", "path": "/bin", "type": "symlink", "size": 0, "mode": "0o777", "target": "usr/bin"},
    {"name": "etc", "path": "/etc", "type": "directory", "size": 4096, "mode": "0o755", "target": null},
    {"name": "root", "path": "/root", "type": "directory", "size": 4096, "mode": "0o700", "target": null}
  ]
}

List Specific Directory

{
  "tool": "list_files",
  "args": {
    "image": "tag:python:3.11-slim",
    "path": "/usr/local/lib/python3.11"
  }
}

Verify File Existence Before Running

// Check if expected file exists
{"tool": "list_files", "args": {"image": "img-uuid", "path": "/app"}}

// If found, run the command
{"tool": "run", "args": {"command": "python /app/main.py", "image": "img-uuid"}}

Best Practices

  • Prefer over run("ls") - list_files is instant and free
  • Verify paths before commands - Check files exist to avoid errors
  • Explore unfamiliar images - Understand structure before running code
  • Check permissions - Verify executable bits and ownership

See Also

  • read_file - Read file contents without VM
  • run - Execute commands (spawns VM)
  • Resources - contree://image/{image}/ls/{path} resource alternative