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
| Name | Type | Description |
|---|---|---|
| $baseUrl | string | Base URL of the MCP server |
| $headers | array<string, string> | Additional HTTP headers |
| $timeout | int | Request timeout in seconds |
| $serverName | (string | null) | Server name for error messages |
HttpSseTransport::connect()
public function connect(): voidVerify the server is reachable by running the MCP `initialize` handshake over HTTP.
HttpSseTransport::disconnect()
public function disconnect(): voidHttpSseTransport::isConnected()
public function isConnected(): boolHttpSseTransport::request()
public function request(string $method, array $params = []): arrayPOST a JSON-RPC request and parse the reply, whether it comes back as SSE or plain JSON.
Parameters
| Name | Type | Description |
|---|---|---|
| $method | string | |
| $params | array<string, mixed> |
HttpSseTransport::notify()
public function notify(string $method, array $params = []): voidPOST a JSON-RPC notification; the response, if any, is discarded.
Parameters
| Name | Type | Description |
|---|---|---|
| $method | string | |
| $params | array<string, mixed> |