include/entropic/mcp/transport.h

← API

include/entropic/mcp/transport.h

entropic::Transport

Abstract transport for external MCP communication.

Derived by entropic::SSETransport, entropic::StdioTransport.

virtual entropic::Transport::~Transport()=default

virtual bool entropic::Transport::open()=0

Open the transport connection.

Returns
true on success.

virtual void entropic::Transport::close()=0

Close the transport connection.

virtual std::string entropic::Transport::send_request(const std::string &request_json, uint32_t timeout_ms=0)=0

Send a JSON-RPC request and wait for response.

Parameters
  • request_json — JSON-RPC request string.
  • timeout_ms — Timeout in milliseconds (0 = default 30s).
Returns
JSON-RPC response string, or empty on error/timeout.

virtual bool entropic::Transport::is_connected() const =0

Check if transport is connected.

Returns
true if connected and ready.

virtual void entropic::Transport::interrupt()

Abort any in-flight send_request() call ASAP.

Called from another thread (typically the engine's interrupt path) so tool dispatches to external MCP servers do not run to completion after Ctrl+C. Default is a no-op for transports with no blocking calls. Must wake pending reads within ~100ms. (P1-10, 2.0.6-rc16)

virtual void entropic::Transport::clear_interrupt()

Release an interrupt so the transport can be used again.

The counterpart to interrupt(). gh#150: without one, a transport that latches on interrupt() stays disabled for the lifetime of the process, because AgentEngine::reset_interrupt() clears only the engine's own flag and never reaches here. Default is a no-op, matching interrupt(): a transport that does not latch has nothing to release.

virtual bool entropic::Transport::is_interrupted() const

Whether an interrupt is currently suppressing this transport.

gh#150: a suppressed transport returns an empty response, which a caller cannot distinguish from a legitimate empty result — the reporting consumer saw status=ok on every call while every call was in fact being dropped. This makes the state answerable.

Returns
true when calls are being short-circuited by an interrupt.