GenMCP.Mux.Channel (gen_mcp v0.9.0)

Copy Markdown View Source

Summary

Functions

Used by server implementations when a channel process exits (generally observed by a monitor). Sets the channel status as closed and prevents sending messages.

Sends a termination message to the open HTTP connection. When this function returns, the HTTP connection may not have terminated yet.

Returns a channel identifying the calling process.

Sends a log message notification to the client if the message level is at or above the channel's configured log level.

Sends a message event with the given data, a binary that will be sent as-is to the client.

Types

log_level()

@type log_level() ::
  :debug | :info | :notice | :warning | :error | :critical | :alert | :emergency

status()

@type status() :: :request | :stream | :closed

t()

@type t() :: %GenMCP.Mux.Channel{
  assigns: map(),
  client: pid() | nil,
  log_level: log_level() | nil,
  progress_token: nil | binary() | integer(),
  status: status()
}

Functions

as_closed(t)

Used by server implementations when a channel process exits (generally observed by a monitor). Sets the channel status as closed and prevents sending messages.

assign(channel, key, value)

@spec assign(t(), atom(), term()) :: t()

close(channel)

Sends a termination message to the open HTTP connection. When this function returns, the HTTP connection may not have terminated yet.

from_request(req, assigns \\ %{})

Returns a channel identifying the calling process.

send_error(channel, error)

send_log(channel, level, data, logger \\ nil)

Sends a log message notification to the client if the message level is at or above the channel's configured log level.

Returns :ok if the message was sent or filtered out, {:error, :closed} if the channel is closed.

send_message(channel, data)

Sends a message event with the given data, a binary that will be sent as-is to the client.

To be a valid SSE event, the data must not contain any newlines.

send_progress(channel, progress, total \\ nil, message \\ nil)

send_result(channel, payload)

set_streaming(t)