1#ifndef SOURCEMETA_CORE_MCP_ERROR_H_
2#define SOURCEMETA_CORE_MCP_ERROR_H_
4#ifndef SOURCEMETA_CORE_MCP_EXPORT
5#include <sourcemeta/core/mcp_export.h>
8#include <sourcemeta/core/error.h>
9#include <sourcemeta/core/http.h>
10#include <sourcemeta/core/json.h>
11#include <sourcemeta/core/jsonrpc.h>
12#include <sourcemeta/core/mcp_protocol.h>
18namespace sourcemeta::core {
20SOURCEMETA_CORE_ERROR_WARNINGS_PUSH
48SOURCEMETA_CORE_ERROR_WARNINGS_POP
101[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
104 std::optional<JSON> data = std::nullopt,
188[[nodiscard]]
constexpr auto
190 const std::int64_t code)
noexcept
191 -> std::optional<HTTPStatus> {
240[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
244 const std::span<const JSON::StringView> supported)
275[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
400[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
auto message() const noexcept -> StaticString
Definition error_base.h:78
Error(const StaticString message) noexcept
Construct the error given its message.
Definition error_base.h:84
constexpr HTTPStatus HTTP_STATUS_BAD_REQUEST
Definition http_status.h:153
constexpr HTTPStatus HTTP_STATUS_NOT_FOUND
Definition http_status.h:173
std::basic_string_view< Char, CharTraits > StringView
The string view type used by the JSON document.
Definition json_value.h:54
constexpr std::int64_t JSONRPC_CODE_METHOD_NOT_FOUND
Definition jsonrpc.h:35
MCPError(const StaticString message) noexcept
Construct an error with a descriptive message.
Definition mcp_error.h:45
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_error(MCPProtocolVersion version, const JSON *identifier, std::int64_t code, JSON::StringView message, std::optional< JSON > data=std::nullopt, MCPErrorContext context=MCPErrorContext::Request) -> JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_error_resource_not_found(const MCPProtocolVersion version, const sourcemeta::core::JSON *identifier) -> sourcemeta::core::JSON
MCPProtocolVersion
Definition mcp_protocol.h:30
constexpr std::int64_t MCP_CODE_MISSING_REQUIRED_CLIENT_CAPABILITY
Definition mcp_error.h:126
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_error_header_mismatch(const MCPProtocolVersion version, const sourcemeta::core::JSON *identifier, const JSON::StringView message) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_error_unsupported_protocol_version(const MCPProtocolVersion version, const sourcemeta::core::JSON *identifier, const JSON::StringView requested, const std::span< const JSON::StringView > supported) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_error_missing_required_capability(const MCPProtocolVersion version, const sourcemeta::core::JSON *identifier, sourcemeta::core::JSON required_capabilities, const JSON::StringView message) -> sourcemeta::core::JSON
constexpr std::int64_t MCP_CODE_RESOURCE_NOT_FOUND
Definition mcp_error.h:110
constexpr auto mcp_error_code_to_http_status(const MCPProtocolVersion version, const std::int64_t code) noexcept -> std::optional< HTTPStatus >
Definition mcp_error.h:189
constexpr std::int64_t MCP_CODE_HEADER_MISMATCH
Definition mcp_error.h:121
constexpr std::int64_t MCP_CODE_UNSUPPORTED_PROTOCOL_VERSION
Definition mcp_error.h:131
MCPErrorContext
Definition mcp_error.h:58
constexpr std::int64_t MCP_CODE_URL_ELICITATION_REQUIRED
Definition mcp_error.h:116
@ V_2026_07_28
The stateless, per-request capability negotiation revision (2026-07-28).
Definition mcp_protocol.h:38
@ Request
A normal request response. Older schemas require a readable identifier.
Definition mcp_error.h:60
@ Transport
Definition mcp_error.h:64
Definition text_static_string.h:20