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;
91 std::string_view
name() const noexcept override;
93 core::Result<core::Unit>
send(TxMessage message) override;
94 core::Result<std::optional<RxMessage>>
receive() override;
95 core::Result<core::Unit>
close() override;
100 std::unique_ptr<Impl> impl_;
106 std::string listen_host =
"127.0.0.1";
112 std::string path =
"/mcp";
120 bool enable_sse_polling =
false;
124 std::chrono::milliseconds sse_disconnect_retry{5000};
131 std::vector<std::string> allowed_hosts = {
"localhost",
"127.0.0.1",
"::1"};
134 std::size_t max_pending_sse_events = 1024;
137 std::size_t max_pending_sse_bytes = 4 * 1024 * 1024;
140 std::size_t max_sse_replay_events = 256;
144 std::chrono::milliseconds request_timeout{30000};
148 std::size_t max_request_body_bytes = 10 * 1024 * 1024;
151 std::chrono::milliseconds read_timeout{30000};
154 std::chrono::milliseconds write_timeout{30000};
158 std::size_t max_sessions = 1024;
162 bool stateless =
false;
168 std::string session_id;
169 std::string remote_address;
170 std::unordered_map<std::string, std::string> headers;
171 std::optional<std::string> http_method;
172 std::optional<std::string> http_url;
192 std::string_view
name() const noexcept override;
193 protocol::Json diagnostics() const override;
194 core::Result<core::Unit> send(TxMessage message) override;
195 core::Result<std::optional<RxMessage>> receive() override;
198 core::Result<core::Unit> close() override;
199 void wait_until_ready() override;
204 std::unique_ptr<Impl> impl_;
Native transport-contract client for Streamable HTTP.
Definition http_transport.hpp:81
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:182
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:70
bool stateless
Enable stateless MCP HTTP mode.
Definition http_transport.hpp:67
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:167
Configuration for a Streamable HTTP server transport.
Definition http_transport.hpp:104
std::optional< std::chrono::milliseconds > sse_retry
Optional SSE retry interval hint for the priming event.
Definition http_transport.hpp:115
std::vector< std::string > allowed_origins
Optional Origin allow-list. Empty means Origin is not restricted.
Definition http_transport.hpp:127
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.