Noizu.MCP.Transport.StreamableHTTP.Plug (Noizu MCP v0.1.0)

Copy Markdown View Source

Streamable HTTP server transport (MCP 2025-11-25): a single MCP endpoint handling POST/GET/DELETE, mountable in Phoenix or any Plug stack:

# Phoenix router
forward "/mcp", Noizu.MCP.Transport.StreamableHTTP.Plug, server: MyApp.MCP

# standalone with Bandit
{Bandit, plug: {Noizu.MCP.Transport.StreamableHTTP.Plug, server: MyApp.MCP}, port: 4040}

Behavior per spec: initialize POSTs create a session and return Mcp-Session-Id; requests answer as application/json when the handler produces only a response, upgrading to an SSE stream when progress, logging, or server-initiated requests flow first; GET opens the general SSE stream (with Last-Event-ID resumability backed by Noizu.MCP.Server.EventStore); DELETE terminates the session.

Options

  • :server (required) — the use Noizu.MCP.Server module
  • :origins:localhost (default; allows non-browser clients and localhost origins), :any, or an explicit allowlist of origins. Origin validation guards against DNS-rebinding attacks.
  • :idle_timeout — session idle expiry in ms (default 30 minutes)
  • :request_timeout — max time to wait for a handler response (default 300_000)
  • :keepalive — SSE keepalive comment interval in ms (default 25_000)
  • :context{module, function} invoked as fun.(conn) returning a map merged into session assigns at initialize (how plug-level auth reaches handlers)