14#include <unordered_map>
19namespace mcp::transport {
25 std::unordered_map<std::string, std::string> headers;
26 std::optional<std::string> www_authenticate;
31 std::function<std::optional<std::string>(
52 std::unordered_map<std::string, std::string>
headers;
86 std::string_view
name() const noexcept override;
88 core::Result<core::Unit>
send(TxMessage message) override;
89 core::Result<std::optional<RxMessage>>
receive() override;
90 core::Result<core::Unit>
close() override;
95 std::unique_ptr<Impl> impl_;
101 std::string listen_host =
"127.0.0.1";
107 std::string path =
"/mcp";
115 bool enable_sse_polling =
false;
119 std::chrono::milliseconds sse_disconnect_retry{5000};
126 std::vector<std::string> allowed_hosts = {
"localhost",
"127.0.0.1",
"::1"};
129 std::size_t max_pending_sse_events = 1024;
132 std::size_t max_pending_sse_bytes = 4 * 1024 * 1024;
135 std::size_t max_sse_replay_events = 256;
139 std::chrono::milliseconds request_timeout{30000};
143 std::size_t max_request_body_bytes = 10 * 1024 * 1024;
146 std::chrono::milliseconds read_timeout{30000};
149 std::chrono::milliseconds write_timeout{30000};
153 std::size_t max_sessions = 1024;
157 bool stateless =
false;
163 std::string session_id;
164 std::string remote_address;
165 std::unordered_map<std::string, std::string> headers;
166 std::optional<std::string> http_method;
167 std::optional<std::string> http_url;
187 std::string_view
name() const noexcept override;
188 protocol::Json diagnostics() const override;
189 core::Result<core::Unit> send(TxMessage message) override;
190 core::Result<std::optional<RxMessage>> receive() override;
193 core::Result<core::Unit> close() override;
194 void wait_until_ready() override;
199 std::unique_ptr<Impl> impl_;
Native transport-contract client for Streamable HTTP.
Definition http_transport.hpp:76
protocol::Json diagnostics() const override
Structured implementation diagnostics.
core::Result< core::Unit > close() override
Closes the transport and unblocks receive() where possible.
std::string_view name() const noexcept override
Human-readable transport name for diagnostics.
core::Result< core::Unit > send(TxMessage message) override
Sends one JSON-RPC message to the peer.
core::Result< std::optional< RxMessage > > receive() override
Receives the next JSON-RPC message from the peer.
Native transport-contract server for Streamable HTTP.
Definition http_transport.hpp:177
std::string_view name() const noexcept override
Human-readable transport name for diagnostics.
Minimal message-level transport contract shared by MCP roles.
Definition transport.hpp:38
HTTP auth challenge observed by Streamable HTTP client transport.
Definition http_transport.hpp:22
Configuration for a Streamable HTTP client transport.
Definition http_transport.hpp:35
std::string uri
Full HTTP or HTTPS URI for the MCP endpoint.
Definition http_transport.hpp:39
std::unordered_map< std::string, std::string > headers
Extra request headers sent on every outbound HTTP request, including Streamable HTTP POST,...
Definition http_transport.hpp:52
int port
Remote TCP port.
Definition http_transport.hpp:45
std::string path
HTTP path used for MCP requests.
Definition http_transport.hpp:48
std::string host
Remote host name or IP address.
Definition http_transport.hpp:42
StreamableHttpAuthRefreshHandler auth_refresh_handler
Optional refresh hook invoked once for a 401 response before surfacing the auth failure.
Definition http_transport.hpp:62
std::chrono::milliseconds timeout
Connect, read, and write timeout used by the transport.
Definition http_transport.hpp:65
std::optional< std::string > auth_header
Optional bearer token inserted as Authorization: Bearer <token> on every outbound HTTP request.
Definition http_transport.hpp:57
HTTP metadata captured for the most recently received server-side Streamable HTTP message.
Definition http_transport.hpp:162
Configuration for a Streamable HTTP server transport.
Definition http_transport.hpp:99
std::optional< std::chrono::milliseconds > sse_retry
Optional SSE retry interval hint for the priming event.
Definition http_transport.hpp:110
std::vector< std::string > allowed_origins
Optional Origin allow-list. Empty means Origin is not restricted.
Definition http_transport.hpp:122
std::function< std::optional< std::string >(const StreamableHttpAuthChallenge &)> StreamableHttpAuthRefreshHandler
Application hook used for one-shot bearer refresh on HTTP 401.
Definition http_transport.hpp:32
Role-generic MCP transport contract for SDK peer/service layers.