# `ConduitMcp.Session.Janitor`
[🔗](https://github.com/nyo16/conduit_mcp/blob/v0.10.1/lib/conduit_mcp/session/janitor.ex#L1)

Periodically prunes expired sessions from a `ConduitMcp.Session.Store`.

ETS-backed stores accumulate session entries indefinitely without an
explicit eviction loop. Without a janitor, every successful `initialize`
request adds a row to the session table that lives until the BEAM restarts;
for a public-facing MCP server this is an unbounded memory growth surface.

Stores backed by systems with native TTL (Redis with `EX`, Mnesia with TTL
indices, etc.) do not need this janitor.

## Usage

Add the janitor to your application supervision tree:

    children = [
      {ConduitMcp.Session.Janitor,
       store: ConduitMcp.Session.EtsStore,
       ttl: :timer.minutes(30),
       interval: :timer.minutes(1)},
      # ...
    ]

## Options

- `:store` (required) — module implementing `ConduitMcp.Session.Store`
  that defines a `cleanup/1` callback.
- `:ttl` — maximum session age in milliseconds (default: 30 minutes).
  Sessions whose `created_at` exceeds this age are evicted.
- `:interval` — interval between cleanup runs in milliseconds
  (default: 1 minute).
- `:name` — registered process name (default: module name).

Emits `[:conduit_mcp, :session, :cleanup]` telemetry on each run with
metadata `%{store: store, removed: count}`.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

---

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