cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
result.hpp File Reference

Shared result and error primitives used by the public cxxmcp SDK. More...

#include <string>
#include <string_view>
#include <tl/expected.hpp>
#include <type_traits>
#include <utility>
#include <variant>

Go to the source code of this file.

Classes

struct  mcp::core::Error
 Structured error returned by fallible SDK operations. More...
 

Typedefs

using mcp::core::Unit = std::monostate
 Success value for operations that only need to report failure.
 
template<typename T >
using mcp::core::Result = tl::expected< T, Error >
 Alias for the SDK result type.
 

Functions

template<class E >
constexpr auto mcp::core::unexpected (E &&value)
 Creates an unexpected result value for the active expected backend.
 
bool mcp::core::starts_with (std::string_view value, std::string_view prefix)
 Compatibility helper matching std::string_view::starts_with.
 
bool mcp::core::starts_with (std::string_view value, char prefix)
 Compatibility helper matching std::string_view::starts_with.
 
bool mcp::core::ends_with (std::string_view value, std::string_view suffix)
 Compatibility helper matching std::string_view::ends_with.
 
bool mcp::core::ends_with (std::string_view value, char suffix)
 Compatibility helper matching std::string_view::ends_with.
 

Detailed Description

Shared result and error primitives used by the public cxxmcp SDK.

This header keeps SDK APIs independent from exceptions at their public boundaries. Operations that can fail return mcp::core::Result with a structured mcp::core::Error so callers can propagate MCP or transport failures without losing protocol error details.

Typedef Documentation

◆ Result

template<typename T >
using mcp::core::Result = typedef tl::expected<T, Error>

Alias for the SDK result type.

Uses tl::expected for every supported C++ standard so compiled SDK libraries and downstream consumers see the same public ABI even when the consumer builds with C++23 or newer. The error side is always mcp::core::Error.

◆ Unit

using mcp::core::Unit = typedef std::monostate

Success value for operations that only need to report failure.

This is used as Result<Unit> in APIs whose successful completion has no payload, mirroring void while still fitting the expected style.