FastestMCP.Resources.File (fastest_mcp v0.1.2)

Copy Markdown View Source

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.

Types

t()

@type t() :: %FastestMCP.Resources.File{
  binary: boolean(),
  encoding: String.t(),
  mime_type: String.t() | nil,
  path: Path.t()
}

Functions

new(path, opts \\ [])

Builds a file-backed resource helper.

read(file)

Reads the file and returns a normalized resource result.