include/entropic/mcp/transport_sse.h

← API

include/entropic/mcp/transport_sse.h

entropic::SSETransport

SSE transport: HTTP GET for event stream, POST for requests.

Inherits from entropic::Transport.

entropic::SSETransport::SSETransport(std::string url, uint32_t default_timeout_ms=30000)

Construct with SSE endpoint URL.

Parameters
  • url — SSE endpoint (e.g., "http://127.0.0.1:6277/sse").
  • default_timeout_ms — Default timeout for send_request.
  • url — SSE endpoint URL.
  • default_timeout_ms — Default request timeout.

entropic::SSETransport::~SSETransport() override

Destructor — ensures reader thread is stopped.

bool entropic::SSETransport::open() override

Connect to SSE endpoint and start reader thread.

Returns
true on success.

void entropic::SSETransport::close() override

Stop SSE reader and close HTTP client.

std::string entropic::SSETransport::send_request(const std::string &request_json, uint32_t timeout_ms=0) override

POST a JSON-RPC request and wait for matching response.

Request and response are decoupled — the POST goes to the message endpoint, the answer arrives on the SSE stream — so responses are matched back by JSON-RPC id.

Parameters
  • request_json — JSON-RPC request string.
  • timeout_ms — Timeout (0 = default).
  • timeout_ms — Timeout in ms (0 = the transport's default).
Returns
  • Response string, or empty on error/timeout.
  • The matching response; an empty string when disconnected, the message endpoint is unknown, the id could not be parsed, the POST failed, or the wait timed out — never a hang.

bool entropic::SSETransport::is_connected() const override

Check if SSE stream is connected.

Returns
true if connected.