Client-side authorization strategy for the Streamable HTTP transport.
Configure on the transport:
{Noizu.MCP.Client,
transport:
{:streamable_http,
url: "https://api.example.com/mcp",
auth: {Noizu.MCP.Auth.Static, token: System.fetch_env!("MCP_TOKEN")}}}Or the full OAuth 2.1 flow — see Noizu.MCP.Auth.OAuth.
Strategy state lives in the transport process; headers/1 is consulted
for every request, and handle_unauthorized/3 runs (serialized) when the
server answers 401, or 403 with an insufficient_scope challenge.
Summary
Types
@type state() :: term()
Callbacks
@callback handle_unauthorized( Noizu.MCP.Auth.WWWAuthenticate.t() | nil, info :: map(), state() ) :: {:retry, state()} | {:error, term(), state()}
React to a 401/403 challenge. Return {:retry, state} to retry the request
with fresh headers/1, or {:error, reason, state} to give up.
Authorization headers for the next request (may refresh tokens).
Initialize. opts includes :mcp_url (the server URL) injected by the transport.