# `McpHouse.Server.SessionStore`
[🔗](https://github.com/HashNuke/mcp_house/blob/main/lib/mcp_house/server/session_store.ex#L1)

Provisional atomic session adapter for a host-mounted MCP endpoint.

Generate each ID from at least 128 cryptographically random bits, encoded
as visible ASCII (for example unpadded base64url). Each operation is atomic with
respect to other operations on the same session. Check the namespace and
principal before reporting a revision mismatch. Expired, closed, foreign
and unknown sessions all return `{:error, :not_found}`. An outage returns
`{:error, :unavailable}`.

TTLs are positive millisecond durations measured by the adapter's own clock.
Successful admission refreshes idle expiry up to the absolute expiry.
Rejection never refreshes it. The initialized notification advances the
phase idempotently; admission may occur immediately after initialize.
Closing prevents new admissions. Already admitted work can finish.

Adapter authors can load `priv/session_store_contract.exs` in ExUnit and
use `McpHouse.Server.SessionStore.Contract` with an isolated store and clock.

# `namespace`

```elixir
@type namespace() :: binary()
```

# `principal`

```elixir
@type principal() :: binary()
```

# `ref`

```elixir
@type ref() :: term()
```

# `rejection`

```elixir
@type rejection() :: {:error, :not_found | :wrong_revision | :unavailable}
```

# `admit`

```elixir
@callback admit(
  ref(),
  namespace(),
  binary(),
  principal(),
  binary(),
  :initialized | :request
) ::
  :ok | rejection()
```

# `close`

```elixir
@callback close(ref(), namespace(), binary(), principal(), binary()) :: :ok | rejection()
```

# `open`

```elixir
@callback open(ref(), namespace(), principal(), binary(), pos_integer(), pos_integer()) ::
  {:ok, binary()} | {:error, :unavailable}
```

---

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