StreamableHTTP
NAME
MCP::Transport::StreamableHTTP - Streamable HTTP transport implementation
DESCRIPTION
Implements the MCP Streamable HTTP transport using Cro::HTTP. Supports client-side POST/GET with SSE, and server-side handling of POST requests plus optional server-initiated SSE streams.
CLASSES
StreamableHTTPServerTransport
Server-side transport that listens on an HTTP endpoint and dispatches JSON-RPC messages received via POST. Supports session management and SSE streaming for server-initiated messages.
my $transport = StreamableHTTPServerTransport.new(
host => 'localhost', port => 8080, path => '/mcp');
Attributes:
hostā Bind address (default:localhost).portā Bind port (default:8080).pathā URL path for the MCP endpoint (default:/mcp).
StreamableHTTPClientTransport
Client-side transport that connects to an MCP HTTP server. Sends JSON-RPC messages via POST and receives responses and server-initiated messages via SSE.
my $transport = StreamableHTTPClientTransport.new(
url => 'http://localhost:8080/mcp');
Attributes:
urlā Server endpoint URL.headersā Optional additional HTTP headers (e.g., for authentication).
Key methods:
terminate-session(--Promise)> ā Send DELETE to terminate the session.