Mcp42.Session (mcp42 v0.1.0)

Copy Markdown

A session process created per Streamable HTTP connection.

The inbox holds server-initiated messages (notifications/request from server) until the transport's SSE stream drains them. Bounded: pushing beyond @inbox_cap intentionally crashes the session (fail-fast backpressure) — the transport observes the :DOWN and tears the stream.

Summary

Functions

Returns a specification to start this module under a supervisor.

Return queued messages in order and empty the inbox.

The session's UUID v4 id (Mcp-Session-Id header value).

Negotiated MCP protocol version (nil until initialize).

Queue a server-initiated message. Fails the session (crash) when the inbox is full; the caller receives {:error, :inbox_full} first.

Record the negotiated protocol version (called on initialize).

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

drain(pid)

Return queued messages in order and empty the inbox.

id(pid)

The session's UUID v4 id (Mcp-Session-Id header value).

protocol_version(pid)

Negotiated MCP protocol version (nil until initialize).

push(pid, message)

Queue a server-initiated message. Fails the session (crash) when the inbox is full; the caller receives {:error, :inbox_full} first.

set_protocol_version(pid, version)

Record the negotiated protocol version (called on initialize).

start_link(opts \\ [])