Sake.Roots (Sake v0.4.3)

Copy Markdown View Source

Asks the client for its roots — the directories or other locations it lets the server work in (roots/list).

case Sake.Roots.list(ctx) do
  {:ok, roots} -> {:ok, Enum.map_join(roots, "\n", & &1.uri)}
  {:error, :unsupported} -> {:error, "This tool needs a client that shares its roots."}
  {:error, _reason} -> {:error, "The client did not list its roots."}
end

Roots are deprecated in the 2026-07-28 revision (SEP-2577) but still part of it, and many clients still use them; Sake supports them on every revision. The call travels exactly like a Sake.Elicit call (see there), keyed by key.

Returns {:ok, [%{uri: uri, name: name}]} (name may be nil), {:error, :unsupported} when the client did not declare roots, or the same errors as Sake.Sampling.create_message/4.

Summary

Types

root()

@type root() :: %{uri: String.t(), name: String.t() | nil}

Functions

list(ctx, key \\ :roots)

@spec list(Sake.Context.t(), atom() | String.t()) ::
  {:ok, [root()]}
  | {:error, :unsupported | :cancelled | :timeout | :invalid_response | map()}