# `Sake.Roots`
[🔗](https://github.com/hattoriai/sake/blob/v0.4.3/lib/sake/roots.ex#L1)

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`.

# `root`

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

# `list`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
