Skip to content
docsv0.1.0

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(): void

Connect to the MCP server.

Throws

McpConnectionException If connection fails

TransportInterface::disconnect()

abstract public function disconnect(): void

Disconnect from the MCP server.

TransportInterface::isConnected()

abstract public function isConnected(): bool

Check if transport is connected.

TransportInterface::request()

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

Send a JSON-RPC request and wait for response.

Parameters

Parameters of request()
NameTypeDescription
$methodstringJSON-RPC method name
$paramsarray<string, mixed>Method parameters

Returns

Response data

Throws

McpTransportException If communication fails

TransportInterface::notify()

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

Send a JSON-RPC notification (no response expected).

Parameters

Parameters of notify()
NameTypeDescription
$methodstringJSON-RPC method name
$paramsarray<string, mixed>Method parameters