livery_mcp (livery v0.2.0)
View SourceMCP Streamable HTTP handler.
Bridges Livery to the barrel_mcp protocol core. handler/1
returns a Livery handler that serves the MCP Streamable HTTP
transport (POST requests, GET SSE streams, DELETE session
termination, OPTIONS preflight) by delegating to
barrel_mcp_http_engine:handle/6 — the transport-neutral MCP
engine. Livery owns the wire (H1/H2/H3, router, middleware); the
engine owns the protocol.
Mount it like any handler, typically at /mcp:
Router = livery_router:compile([
{<<"POST">>, <<"/mcp">>, livery_mcp:handler()},
{<<"GET">>, <<"/mcp">>, livery_mcp:handler()},
{<<"DELETE">>, <<"/mcp">>, livery_mcp:handler()}
]),
livery:start_service(#{https => #{...}, router => Router}).Register tools, resources, and prompts through barrel_mcp's own
API (barrel_mcp:reg_tool/4 and friends); they live in the shared
barrel_mcp_registry. The barrel_mcp application must be running
(it is started transitively as a Livery dependency).
Options (all optional):
auth— abarrel_mcpauth provider config (default: no auth)session_enabled— useMcp-Session-Idsessions (defaulttrue)allowed_origins—any | [binary()](defaultany)allow_missing_origin— accept requests with noOrigin(defaulttrue)sse_buffer_size— server-stream buffer (default256)resource_metadata— OAuth protected-resource-metadata map
The handler delivers the response directly through the adapter and
returns the taken_over sentinel, so do not stack response-mutating
middleware after it.
Summary
Functions
MCP handler with default options.
MCP handler built from Opts (see the module docs).
A router for the MCP endpoint at /mcp, ready to mount with
livery_router:nest/3 or merge/2.
router/0 with MCP handler options.
Types
Functions
-spec handler() -> fun((livery_req:req()) -> livery_resp:resp()).
MCP handler with default options.
-spec handler(opts()) -> fun((livery_req:req()) -> livery_resp:resp()).
MCP handler built from Opts (see the module docs).
-spec router() -> livery_router:router().
A router for the MCP endpoint at /mcp, ready to mount with
livery_router:nest/3 or merge/2.
-spec router(opts()) -> livery_router:router().
router/0 with MCP handler options.