class

Smith::MCP::HttpTransport

Inherits Smith::MCP::Transport < Reference < Object

A Streamable-HTTP connection to a remote MCP server: JSON-RPC messages go out as POSTs, answers come back either as a JSON body or as an SSE stream — the spec requires the client to accept both, so both are read.

Fitted into the same Transport interface stdio uses: send enqueues a message and the answers land on receive, matched by id in the client's reader fiber. That keeps the restart-once logic, the approval gate and the untrusted marking exactly where they already are.

Constants

CLOSE_TIMEOUT = 2.seconds

Telling a server the session is over must never hold up shutdown — a server that is already gone cannot be told anyway.

CONNECT_TIMEOUT = 10.seconds

Connecting to a host that routes into nowhere must not hang the session start for the full call timeout.

Constructors

new(url : URI, headers : Hash(String, String) = Hash(String, String).new, read_timeout : Time::Span = Client::DEFAULT_TIMEOUT)
Source

Instance methods

close
Source
failure_hint

Why the stream died, when the transport knows more than "EOF". stdio has nothing to add; an HTTP transport can say which status or which network error it was. Read once, when the pending callers are abandoned.

Source
receive

nil at end of stream. Blocking; called only from the reader fiber.

Source
send(line : String) : Nil

One complete message. Framing is line-based, so neither side may embed a raw newline — JSON escapes them, which is why this works at all.

Source