Backplane.McpProtocol.Transport.StreamableHTTP.Headers (backplane_mcp_protocol v0.6.0)

Copy Markdown

Builds request-local Streamable HTTP headers for legacy and modern MCP sends.

Modern routing fields are derived from the encoded wire request so configured values cannot disagree with the body that is actually sent.

Summary

Functions

Validates configured headers and canonicalizes their names to lower case.

Encodes one mirrored primitive using the MCP lower-case base64 sentinel.

Validates configured legacy headers and removes modern routing fields.

Validates and encodes a set of declared Mcp-Param-* headers.

Adds the negotiated legacy protocol header when that revision requires it.

Functions

build(base_headers, encoded_message, context)

@spec build(
  map() | list(),
  binary(),
  Backplane.McpProtocol.Transport.RequestContext.t() | nil
) ::
  {:ok, map()} | {:error, term()}

configured(headers)

@spec configured(map() | list()) :: {:ok, map()} | {:error, term()}

Validates configured headers and canonicalizes their names to lower case.

encode_mirrored(value)

@spec encode_mirrored(term()) :: {:ok, String.t()} | :omit | {:error, atom()}

Encodes one mirrored primitive using the MCP lower-case base64 sentinel.

legacy_configured(headers)

@spec legacy_configured(map() | list()) :: {:ok, map()} | {:error, term()}

Validates configured legacy headers and removes modern routing fields.

parameter_headers(headers)

@spec parameter_headers(map()) :: {:ok, map()} | {:error, term()}

Validates and encodes a set of declared Mcp-Param-* headers.

put_legacy_protocol_header(headers, version)

@spec put_legacy_protocol_header(map(), String.t() | nil) :: map()

Adds the negotiated legacy protocol header when that revision requires it.