TransportInterface
Interface for MCP transport implementations. Transports handle the low-level communication with MCP servers. Supported transports: - HTTP/SSE: For remote MCP servers (like Cloudflare) - Stdio: For local MCP servers spawned as subprocesses (like Namecheap)
TransportInterface::connect()
abstract public function connect(): voidConnect to the MCP server.
Throws
McpConnectionException If connection fails
TransportInterface::disconnect()
abstract public function disconnect(): voidDisconnect from the MCP server.
TransportInterface::isConnected()
abstract public function isConnected(): boolCheck if transport is connected.
TransportInterface::request()
abstract public function request(string $method, array $params = []): arraySend a JSON-RPC request and wait for response.
Parameters
| Name | Type | Description |
|---|---|---|
| $method | string | JSON-RPC method name |
| $params | array<string, mixed> | Method parameters |
Returns
Response data
Throws
McpTransportException If communication fails
TransportInterface::notify()
abstract public function notify(string $method, array $params = []): voidSend a JSON-RPC notification (no response expected).
Parameters
| Name | Type | Description |
|---|---|---|
| $method | string | JSON-RPC method name |
| $params | array<string, mixed> | Method parameters |