ExMCP.HttpPlug.Core (ex_mcp v1.0.0-rc.0)

View Source

Pure request/response decisions for ExMCP.HttpPlug.

The Plug module owns side effects such as reading request bodies, writing responses, ETS/session management, and SSE processes. This module keeps the reusable protocol and origin decisions as data transformations.

Summary

Types

origin_context()

@type origin_context() :: %{
  optional(:origin) => String.t() | nil,
  optional(:scheme) => String.t(),
  optional(:host) => String.t(),
  optional(:port) => non_neg_integer() | nil
}

Functions

cors_response_origin(context, opts)

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

json_rpc_error(code, message, id \\ nil, data \\ nil)

@spec json_rpc_error(integer(), String.t(), any(), map() | nil) :: map()

oauth_guard_disabled_error()

@spec oauth_guard_disabled_error() :: map()

origin_allowed?(context, opts)

@spec origin_allowed?(origin_context(), map()) :: boolean()

parse_json(body)

@spec parse_json(binary()) ::
  {:ok, map()} | {:error, :parse_error | :invalid_json_rpc_envelope}