FastestMCP.Root (fastest_mcp v0.2.0)

Copy Markdown View Source

A client-declared MCP filesystem root.

MCP 2025-11-25 restricts roots to file:// URIs. This module normalizes those URIs before they enter session state and provides boundary checks that compare complete path segments rather than unsafe string prefixes.

contains?/2 is a URI-level check and does not access the local filesystem. Use safe_realpath/2 when a root refers to the server's local filesystem and symlink-aware containment is required.

Summary

Functions

Returns whether a file URI is equal to or below the supplied root.

Builds a canonical file root from a local absolute or relative path.

Builds and validates a canonical root, raising on invalid input.

Parses a root URI or tagged-schema root map.

Returns the decoded, normalized absolute path represented by a root.

Resolves a local path and verifies symlink-aware containment in the root.

Returns the tagged MCP wire representation.

Types

t()

@type t() :: %FastestMCP.Root{
  meta: map() | nil,
  name: String.t() | nil,
  uri: String.t()
}

Functions

contains?(root, candidate)

Returns whether a file URI is equal to or below the supplied root.

from_path(path, opts \\ [])

Builds a canonical file root from a local absolute or relative path.

new(uri, opts \\ [])

Builds and validates a canonical root, raising on invalid input.

parse(value, opts \\ [])

Parses a root URI or tagged-schema root map.

path(root)

Returns the decoded, normalized absolute path represented by a root.

safe_realpath(root, candidate)

Resolves a local path and verifies symlink-aware containment in the root.

to_wire(root)

Returns the tagged MCP wire representation.