20namespace mcp::protocol {
42template <
class Params,
class Result>
53 template <
class Serializer>
61 template <
class Deserializer>
63 Deserializer deserializer)
const {
65 return mcp::core::unexpected(
67 response.
error->data.value_or(Json::object())});
70 return mcp::core::unexpected(
71 core::Error{
static_cast<int>(ErrorCode::InternalError),
72 "custom request response has neither result nor error",
75 return deserializer(*response.
result);
90template <
class Params>
100 template <
class Serializer>
Shared JSON, JSON-RPC, error, cancellation, and progress model types.
std::variant< std::int64_t, std::string > RequestId
JSON-RPC request or response identifier.
Definition types.hpp:56
Shared result and error primitives used by the public cxxmcp SDK.
tl::expected< T, Error > Result
Alias for the SDK result type.
Definition result.hpp:64
JSON-RPC method names and message construction/parsing helpers.
JsonRpcNotification make_notification(std::string method, Json params=Json::object())
Builds a generic JSON-RPC notification envelope.
JsonRpcRequest make_request(std::string method, RequestId id, Json params=Json::object())
Builds a generic JSON-RPC request envelope.
Structured error returned by fallible SDK operations.
Definition result.hpp:35
Generic typed MCP notification for extension methods.
Definition custom_methods.hpp:91
Params params
Typed notification parameters.
Definition custom_methods.hpp:95
std::string method
Method name on the wire.
Definition custom_methods.hpp:93
JsonRpcNotification to_json_rpc(Serializer serializer) const
Creates a JsonRpcNotification envelope from this typed notification.
Definition custom_methods.hpp:101
Generic typed MCP request for extension methods.
Definition custom_methods.hpp:43
Params params
Typed request parameters.
Definition custom_methods.hpp:47
core::Result< Result > parse_response(const JsonRpcResponse &response, Deserializer deserializer) const
Parses a JsonRpcResponse into a typed Result.
Definition custom_methods.hpp:62
RequestId id
Request id for JSON-RPC correlation.
Definition custom_methods.hpp:49
std::string method
Method name on the wire.
Definition custom_methods.hpp:45
JsonRpcRequest to_json_rpc(Serializer serializer) const
Creates a JsonRpcRequest envelope from this typed request.
Definition custom_methods.hpp:54
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
JSON-RPC response envelope for either success or failure.
Definition types.hpp:115
bool has_result() const noexcept
Returns true when this response contains a successful result.
Definition types.hpp:126
bool has_error() const noexcept
Returns true when this response contains an error object.
Definition types.hpp:131
std::optional< Json > result
Successful method result. Mutually exclusive with error.
Definition types.hpp:119
std::optional< ErrorObject > error
JSON-RPC error object. Mutually exclusive with result.
Definition types.hpp:121