Helper for serving file-backed resources.
This helper keeps the common file-resource edge cases in one place:
- absolute-path validation
- UTF-8 text reads by default
- explicit binary mode
- encoding overrides
- normalized read errors
Example
file = FastestMCP.Resources.File.new("/tmp/report.txt")
FastestMCP.add_resource(server, "file:///tmp/report.txt", fn _arguments, _ctx ->
FastestMCP.Resources.File.read(file)
end)
Summary
Functions
Builds a file-backed resource helper.
Reads the file and returns a normalized resource result.