AttestoMCP.Server.Session (attesto_mcp_server v0.14.0)

Copy Markdown View Source

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.

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.

Summary

Functions

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

Returns the largest session timeout accepted by all session stores.

Serializes persistent session state without live processes or callbacks.

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

Types

t()

@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()
}

Functions

from_record(record)

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

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

max_timeout_ms()

@spec max_timeout_ms() :: pos_integer()

Returns the largest session timeout accepted by all session stores.

new(principal, tenant, opts \\ [])

same_principal?(session, actual)

same_tenant?(session, actual)

to_record(session)

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

Serializes persistent session state without live processes or callbacks.

touch(session)

valid?(session, now \\ System.system_time(:millisecond))

valid_timeout?(value)

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

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