Skip to content
docsv0.1.0

HttpSseTransport

HTTP/SSE Transport for MCP servers. This transport is used for remote MCP servers like Cloudflare's. Communication flow: 1. Client sends JSON-RPC request via HTTP POST 2. Server responds via Server-Sent Events (SSE) or direct JSON response

HttpSseTransport::__construct()

public function __construct(string $baseUrl, array $headers = [], int $timeout = 30, ?string $serverName = null):

Parameters

Parameters of __construct()
NameTypeDescription
$baseUrlstringBase URL of the MCP server
$headersarray<string, string>Additional HTTP headers
$timeoutintRequest timeout in seconds
$serverName(string | null)Server name for error messages

HttpSseTransport::connect()

public function connect(): void

Verify the server is reachable by running the MCP `initialize` handshake over HTTP.

HttpSseTransport::disconnect()

public function disconnect(): void

HttpSseTransport::isConnected()

public function isConnected(): bool

HttpSseTransport::request()

public function request(string $method, array $params = []): array

POST a JSON-RPC request and parse the reply, whether it comes back as SSE or plain JSON.

Parameters

Parameters of request()
NameTypeDescription
$methodstring
$paramsarray<string, mixed>

HttpSseTransport::notify()

public function notify(string $method, array $params = []): void

POST a JSON-RPC notification; the response, if any, is discarded.

Parameters

Parameters of notify()
NameTypeDescription
$methodstring
$paramsarray<string, mixed>