14#include <unordered_map>
18namespace mcp::client {
27 std::unordered_map<std::string, std::string>
headers;
50 std::unordered_map<std::string, std::string>
headers;
95 void stop() noexcept override;
104 std::unique_ptr<Impl> impl_;
Client transport that exchanges MCP JSON-RPC messages over HTTP.
Definition http_transport.hpp:71
core::Result< protocol::JsonRpcResponse > send(const protocol::JsonRpcRequest &request) override
Sends one JSON-RPC request to the HTTP endpoint.
core::Result< core::Unit > start(TransportRequestHandler request_handler, TransportNotificationHandler notification_handler={}) override
Starts receive-side handling for server-initiated messages.
void stop() noexcept override
Stops background receive activity and releases transport resources.
HttpTransport(HttpTransportOptions options)
Creates an HTTP transport from endpoint options.
void set_negotiated_protocol_version(std::string version)
Updates the negotiated protocol version for subsequent requests.
core::Result< core::Unit > send_notification(const protocol::JsonRpcNotification ¬ification) override
Sends a JSON-RPC notification to the HTTP endpoint.
Abstract client transport used by Client to exchange JSON-RPC messages.
Definition client.hpp:83
Core client compatibility API and transport interface for MCP clients.
std::function< core::Result< core::Unit >(const protocol::JsonRpcNotification &)> TransportNotificationHandler
Handles JSON-RPC notifications sent by the server to this client.
Definition client.hpp:75
std::function< core::Result< protocol::JsonRpcResponse >(const protocol::JsonRpcRequest &)> TransportRequestHandler
Handles JSON-RPC requests sent by the server to this client.
Definition client.hpp:68
tl::expected< T, Error > Result
Alias for the SDK result type.
Definition result.hpp:64
HTTP auth challenge observed by the client transport.
Definition http_transport.hpp:21
std::unordered_map< std::string, std::string > headers
Response headers copied from the failed HTTP response.
Definition http_transport.hpp:27
int status_code
HTTP status code, normally 401 or 403.
Definition http_transport.hpp:23
std::string method
Request method name that received the challenge.
Definition http_transport.hpp:25
std::optional< std::string > www_authenticate
First WWW-Authenticate header value, when present.
Definition http_transport.hpp:29
Configuration for the client HTTP transport.
Definition http_transport.hpp:33
int port
Remote TCP port.
Definition http_transport.hpp:43
std::string host
Remote host name or IP address.
Definition http_transport.hpp:40
HttpAuthRefreshHandler auth_refresh_handler
Optional refresh hook invoked once for a 401 response before surfacing the auth failure.
Definition http_transport.hpp:60
std::chrono::milliseconds timeout
Connect, read, and write timeout used by the transport.
Definition http_transport.hpp:63
std::string uri
Full HTTP or HTTPS URI for the MCP endpoint.
Definition http_transport.hpp:37
std::string path
HTTP path used for MCP requests.
Definition http_transport.hpp:46
std::optional< std::string > auth_header
Optional bearer token inserted as Authorization: Bearer <token> on every outbound HTTP request.
Definition http_transport.hpp:55
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:50
JSON-RPC notification envelope for one-way MCP messages.
Definition types.hpp:137
JSON-RPC request envelope carrying an MCP method invocation.
Definition types.hpp:99