Helper for serving directory listings as JSON resources.
This helper covers the common directory-resource cases:
- absolute-path validation
- non-recursive or recursive file listing
- optional hidden-file inclusion
- normalized read errors
read/1 returns a FastestMCP.Resources.Result with one JSON content item.
That keeps the result transport-safe while still making the directory listing
explicit and inspectable in Elixir code.
Example
directory = FastestMCP.Resources.Directory.new("/tmp/reports", recursive: true)
FastestMCP.add_resource(server, "dir:///tmp/reports", fn _arguments, _ctx ->
FastestMCP.Resources.Directory.read(directory)
end)
Summary
Functions
Lists files in the configured directory.
Builds a directory-listing resource helper.
Reads the directory listing and returns a normalized resource result.