barrel_mcp_http_listener (barrel_mcp v2.0.2)

View Source

Built-in HTTP/1.1 + HTTP/2 server for the MCP HTTP transports.

A small acceptor pool on a single port, built on the h1 and h2 protocol libraries (no cowboy). Cleartext binds speak HTTP/1.1; TLS binds advertise ALPN [h2, http/1.1] and dispatch each connection to the negotiated protocol — so one URL serves both, like the cowboy listener it replaces.

Per accepted connection a process owns the socket, performs the TLS handshake (TLS only), starts an h1_connection/h2_connection in server mode and runs the owner loop. Each request is handled in its own process that reads the body, builds a barrel_mcp_http_engineResponder over h1/h2:send_response/send_data, and runs the engine.

The engine, not this module, holds the MCP protocol logic; this module is pure transport plumbing.

Summary

Functions

Start a listener registered as Name.

Stop a listener by registered name.

Functions

connection_init(Transport, Handler, Listener)

start(Name, ListenOpts, EngineConfig)

-spec start(atom(), map(), barrel_mcp_http_engine:config()) -> {ok, pid()} | {error, term()}.

Start a listener registered as Name.

ListenOpts: #{port, ip, ssl, acceptors, max_connections}. ssl is undefined (cleartext) or #{certfile, keyfile, cacertfile => _}. EngineConfig is passed verbatim to barrel_mcp_http_engine:handle/6.

stop(Name)

-spec stop(atom()) -> ok | {error, not_found}.

Stop a listener by registered name.