# `AttestoMCP.Server.Session`
[🔗](https://github.com/XukuLLC/attesto_mcp_server/blob/v2.8.0/lib/attesto_mcp_server/session.ex#L1)

Bounded session records for session-bound MCP revisions, with principal
binding and expiry.

Durable adapters store the versioned JSON-compatible value returned by
`to_record/1`. Live stream references are intentionally excluded and must be
reopened after a server or node restart. Unknown record fields are ignored;
malformed or oversized current-version records fail closed. Higher integer
format versions remain opaque and are preserved by the bundled stores.

The `principal` field stores an identity binding, not necessarily the richer
principal value exposed to request handlers. Principal and tenant bindings
may contain existing atoms because they are
encoded as bounded Erlang terms. Safe restoration never creates atoms from
persisted data, so an atom-bearing binding can be used only on nodes where
those atoms already exist. A node that cannot safely decode such a binding
reports `:binding_unavailable`; durable adapters must preserve the record and
callers should treat it as unavailable until the required atoms are loaded.

# `t`

```elixir
@type t() :: %AttestoMCP.Server.Session{
  absolute_timeout: term(),
  client_capabilities: term(),
  created_at: term(),
  id: term(),
  idle_timeout: term(),
  initialized: term(),
  last_seen: term(),
  logging_level: term(),
  principal: term(),
  resource_subscriptions: term(),
  streams: term(),
  tenant: term(),
  version: term()
}
```

# `from_record`

```elixir
@spec from_record(map()) :: {:ok, t()} | {:error, term()}
```

Restores a durable session record with empty live-stream state.

# `max_timeout_ms`

```elixir
@spec max_timeout_ms() :: pos_integer()
```

Returns the largest session timeout accepted by all session stores.

# `new`

# `same_principal?`

# `same_tenant?`

# `to_record`

```elixir
@spec to_record(t()) :: {:ok, map()} | {:error, term()}
```

Serializes persistent session state without live processes or callbacks.

# `touch`

# `valid?`

# `valid_timeout?`

```elixir
@spec valid_timeout?(term()) :: boolean()
```

Checks the common positive, signed-BIGINT-safe session timeout range.

---

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