# `OzMcp.Auth.Scopes`
[🔗](https://github.com/oz-elixir/oz_mcp/blob/v0.9.0/lib/oz_mcp/auth/scopes.ex#L1)

The scopes that a tool, a resource, a template or a prompt requires.

A list of required scopes means "all of them". The data lives in the
field `required_scopes` of the struct of the entity. A map entity
carries them like a struct: the boot of the instance reads the key
and checks it and the key never reaches the client.

# `check!`

```elixir
@spec check!(term()) :: [String.t()]
```

Check the value of a `required_scopes` declaration and return the scopes
with no repeated entry. Raises `ArgumentError`.

# `declared`

```elixir
@spec declared(module()) :: [String.t()]
```

All the scopes that the modules of the server require, sorted. The
function reads the catalog of the server, which holds the scopes of
the entities of each kind. It never calls `list/0` of a module: the
catalog was read one time, at the boot of the instance.

# `declared`

```elixir
@spec declared(module(), atom()) :: [String.t()]
```

The scopes that the modules of one kind (`:tools`, `:resources`,
`:templates` or `:prompts`) declare: the `required_scopes` of the
entities of the kind, which the catalog holds. Sorted. Empty when the
kind has no block, or when no entity of the kind needs a scope.

# `granted?`

```elixir
@spec granted?(OzMcp.Auth.Principal.t(), [String.t()]) :: boolean()
```

True when the principal holds all the scopes.

# `required`

```elixir
@spec required(term()) :: [String.t()]
```

The required scopes of an entity. A map or `nil` has none. The bind
stage of the pipeline (OzMcp.Pipeline.Bind) copies them into the
field `required_scopes` of the bound entity, where the scope stage and
the list filters read them.

# `step_up`

```elixir
@spec step_up(OzMcp.Auth.Principal.t(), [String.t()], [String.t()]) :: [String.t()]
```

The `scope` of a step-up challenge: the scopes that the principal
holds, then the needed scopes that are not in the list. `needed` empty
means the `challenge_scopes` of the server. A granted scope that is not
an RFC 6749 scope token is dropped: it cannot go in the header.

# `supported`

```elixir
@spec supported(module(), map()) :: [String.t()] | nil
```

The `scopes_supported` of the metadata document: the list that the
server sets, or else the scopes that the modules of the server
require, or `nil` when there is neither.

# `visible?`

```elixir
@spec visible?(term(), OzMcp.Auth.Principal.t()) :: boolean()
```

True when the principal can use the entity (the entity needs no scope, or the principal holds them).

---

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