1#ifndef SOURCEMETA_CORE_MCP_RESULTS_H_
2#define SOURCEMETA_CORE_MCP_RESULTS_H_
4#ifndef SOURCEMETA_CORE_MCP_EXPORT
5#include <sourcemeta/core/mcp_export.h>
8#include <sourcemeta/core/json.h>
9#include <sourcemeta/core/mcp_capabilities.h>
10#include <sourcemeta/core/mcp_headers.h>
11#include <sourcemeta/core/mcp_protocol.h>
21namespace sourcemeta::core {
48[[nodiscard]]
constexpr auto
58#if !defined(__clang__)
76[[nodiscard]]
constexpr auto
78 -> std::optional<MCPCacheScope> {
79 if (scope ==
"public") {
82 if (scope ==
"private") {
136 std::optional<std::span<const JSON::StringView>>
audience = std::nullopt;
187[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
219[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
243[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
271[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
294[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
314[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
373 const std::optional<MCPImplementation> &server_info = std::nullopt)
436 const std::optional<MCPImplementation> &server_info = std::nullopt)
474 const std::optional<MCPImplementation> &server_info = std::nullopt)
510 const std::optional<MCPImplementation> &server_info = std::nullopt)
541 const std::optional<MCPImplementation> &server_info = std::nullopt)
565[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
569 const std::optional<std::size_t> size = std::nullopt,
570 const std::optional<double> priority = std::nullopt,
571 const MCPDescriptorPresentation &presentation = {},
572 const MCPResourceAnnotations &annotations = {})
573 -> sourcemeta::core::JSON;
693 std::optional<sourcemeta::core::JSON> output_schema = std::nullopt,
695 const MCPDescriptorPresentation &presentation = {})
724 const std::optional<JSON::StringView> next_cursor,
759 const std::optional<JSON::StringView> next_cursor,
786[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
789 const std::optional<JSON::StringView> next_cursor,
820 const std::optional<JSON::StringView> next_cursor,
853[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
877[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
879 std::optional<std::int64_t> total,
880 std::optional<bool> has_more) ->
JSON;
921SOURCEMETA_CORE_MCP_EXPORT
924 const JSON &identifier,
const JSON &result,
925 std::optional<MCPCachePolicy> cache_policy,
926 std::optional<MCPImplementation> server_info = std::nullopt) -> void;
940SOURCEMETA_CORE_MCP_EXPORT
943 const JSON &identifier,
JSON &&result,
944 std::optional<MCPCachePolicy> cache_policy,
945 std::optional<MCPImplementation> server_info = std::nullopt) -> void;
1011 const std::span<const JSON::StringView> supported_versions,
1050 const std::span<const JSON::StringView> supported_versions,
1102 std::optional<sourcemeta::core::JSON> input_requests,
1103 std::optional<JSON::StringView> request_state,
1105 const std::optional<MCPImplementation> &server_info = std::nullopt)
1136[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1162[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1165 -> std::optional<JSON::StringView>;
1215[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1217 const JSON ¶meters)
1218 -> std::optional<MCPSubscriptionFilter>;
1242[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1269[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1301 std::span<const JSON::StringView> supported_extension_types = {})
1302 -> std::optional<JSON::StringView>;
1343[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1345 const JSON &input_requests) -> bool;
1380[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1382 const JSON &input_requests,
1383 std::optional<JSON::StringView> expected_state)
1416[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1419 std::optional<JSON> subscription_id,
1450[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1482[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1504[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1507 const std::optional<MCPImplementation> &server_info = std::nullopt)
1533[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
1560[[nodiscard]] SOURCEMETA_CORE_MCP_EXPORT
auto
@ Public
Definition http.h:350
@ Private
Definition http.h:353
std::basic_string_view< Char, CharTraits > StringView
The string view type used by the JSON document.
Definition json_value.h:54
JSON::StringView title
Optional human-readable title for the tool.
Definition mcp_results.h:116
std::optional< bool > prompts_list_changed
Opt in to notifications that the prompt list changed.
Definition mcp_results.h:1178
std::optional< bool > tools_list_changed
Opt in to notifications that the tool list changed.
Definition mcp_results.h:1176
bool destructive
true when the tool may mutate or delete state.
Definition mcp_results.h:120
bool idempotent
Definition mcp_results.h:123
const JSON * icons
Optional icon array (2025-11-25 and later).
Definition mcp_results.h:159
std::int64_t ttl_ms
Definition mcp_results.h:101
std::optional< bool > resources_list_changed
Opt in to notifications that the resource list changed.
Definition mcp_results.h:1180
bool open_world
true when the tool interacts with state outside the server's control.
Definition mcp_results.h:125
std::optional< std::vector< JSON::StringView > > resource_subscriptions
Definition mcp_results.h:1183
std::optional< double > priority
Definition mcp_results.h:142
std::optional< std::span< const JSON::StringView > > audience
Optional audience roles ("user" and/or "assistant"). Empty stays explicit.
Definition mcp_results.h:136
bool read_only
true as an advisory hint that the tool does not modify its environment.
Definition mcp_results.h:118
MCPCacheScope scope
Cache scope (public or private).
Definition mcp_results.h:103
JSON::StringView title
Human-readable title (2025-06-18 and later).
Definition mcp_results.h:157
JSON::StringView last_modified
Optional timestamp string. The caller supplies a valid ISO 8601 timestamp.
Definition mcp_results.h:144
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_tool_error(const MCPProtocolVersion version, const sourcemeta::core::JSON &identifier, const JSON::StringView message, const std::optional< MCPImplementation > &server_info=std::nullopt) -> sourcemeta::core::JSON
MCPCacheScope
Definition mcp_results.h:28
SOURCEMETA_CORE_MCP_EXPORT auto mcp_decorate_result(const MCPProtocolVersion version, sourcemeta::core::JSON result, const std::optional< MCPImplementation > &server_info=std::nullopt) -> sourcemeta::core::JSON
constexpr auto mcp_cache_scope_string(const MCPCacheScope scope) noexcept -> JSON::StringView
Definition mcp_results.h:49
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_tool_descriptor(const MCPProtocolVersion version, const JSON::StringView name, const JSON::StringView description, sourcemeta::core::JSON input_schema, std::optional< sourcemeta::core::JSON > output_schema=std::nullopt, const MCPToolAnnotations &annotations={}, const MCPDescriptorPresentation &presentation={}) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_resource_blob_content(JSON::StringView uri, JSON::StringView mime_type, JSON::StringView blob) -> JSON
MCPProtocolVersion
Definition mcp_protocol.h:30
SOURCEMETA_CORE_MCP_EXPORT auto mcp_validate_continuation(MCPProtocolVersion version, const JSON ¶meters, const JSON &input_requests) -> bool
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_resource_link(const MCPProtocolVersion version, const JSON::StringView uri, const JSON::StringView name, const JSON::StringView mime_type={}, const JSON::StringView description={}) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_tool_call_arguments(const sourcemeta::core::JSON &envelope) -> const sourcemeta::core::JSON *
SOURCEMETA_CORE_MCP_EXPORT auto mcp_request_input_responses(MCPProtocolVersion version, const sourcemeta::core::JSON &envelope) -> const sourcemeta::core::JSON *
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_subscription_acknowledged_notification(const MCPProtocolVersion version, const sourcemeta::core::JSON &subscription_id, const MCPSubscriptionFilter &requested, const MCPSubscriptionFilter &supported) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_write_result(std::ostream &stream, MCPProtocolVersion version, JSON::StringView method, const JSON &identifier, const JSON &result, std::optional< MCPCachePolicy > cache_policy, std::optional< MCPImplementation > server_info=std::nullopt) -> void
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_prompts_list_result(const MCPProtocolVersion version, sourcemeta::core::JSON prompts, const std::optional< JSON::StringView > next_cursor, const MCPCachePolicy &cache_policy) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_intersect_subscription_filters(const MCPSubscriptionFilter &requested, const MCPSubscriptionFilter &supported) -> MCPSubscriptionFilter
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_subscription_close_response(const MCPProtocolVersion version, const sourcemeta::core::JSON &identifier, const std::optional< MCPImplementation > &server_info=std::nullopt) -> sourcemeta::core::JSON
constexpr auto mcp_resolve_cache_scope(const JSON::StringView scope) noexcept -> std::optional< MCPCacheScope >
Definition mcp_results.h:77
SOURCEMETA_CORE_MCP_EXPORT auto mcp_parse_subscription_filter(MCPProtocolVersion version, const JSON ¶meters) -> std::optional< MCPSubscriptionFilter >
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_tool_success(const MCPProtocolVersion version, const sourcemeta::core::JSON &identifier, sourcemeta::core::JSON result, const std::optional< MCPImplementation > &server_info=std::nullopt) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_resources_read_result(const MCPProtocolVersion version, sourcemeta::core::JSON contents, const MCPCachePolicy &cache_policy) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_request_subscription_id(MCPProtocolVersion version, const sourcemeta::core::JSON &envelope) -> const sourcemeta::core::JSON *
SOURCEMETA_CORE_MCP_EXPORT auto mcp_request_state(MCPProtocolVersion version, const sourcemeta::core::JSON &envelope) -> std::optional< JSON::StringView >
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_completion_result(MCPProtocolVersion version, JSON values, std::optional< std::int64_t > total, std::optional< bool > has_more) -> JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_image_block(MCPProtocolVersion version, JSON::StringView data, JSON::StringView mime_type, const MCPResourceAnnotations &annotations={}) -> JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_decorate_cacheable_result(const MCPProtocolVersion version, sourcemeta::core::JSON result, const MCPCachePolicy &cache_policy, const JSON::StringView method) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_notification(MCPProtocolVersion version, bool from_server, JSON::StringView method, JSON parameters, std::optional< JSON > subscription_id, const MCPSubscriptionFilter *acknowledged=nullptr, const MCPRequestMeta *request_context=nullptr) -> JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_prompts_get_result(MCPProtocolVersion version, JSON::StringView description, JSON messages) -> JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_initialize_response(const sourcemeta::core::JSON &request, const MCPServerCapabilities &capabilities, const MCPImplementation &server, const std::span< const JSON::StringView > supported_versions, const JSON::StringView instructions={}) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_resources_list_result(const MCPProtocolVersion version, sourcemeta::core::JSON resources, const std::optional< JSON::StringView > next_cursor, const MCPCachePolicy &cache_policy) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_text_block(const JSON::StringView text) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_tools_list_result(const MCPProtocolVersion version, sourcemeta::core::JSON tools, const std::optional< JSON::StringView > next_cursor, const MCPCachePolicy &cache_policy) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_resource_template(const MCPProtocolVersion version, const JSON::StringView uri_template, const JSON::StringView name, const JSON::StringView description, const JSON::StringView mime_type, const MCPDescriptorPresentation &presentation={}, const MCPResourceAnnotations &annotations={}) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_resource_text_content(const JSON::StringView uri, const JSON::StringView mime_type, const JSON::StringView text) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_input_required_response(const MCPProtocolVersion version, const JSON::StringView method, const sourcemeta::core::JSON &identifier, std::optional< sourcemeta::core::JSON > input_requests, std::optional< JSON::StringView > request_state, const MCPClientCapabilities &client_capabilities, const std::optional< MCPImplementation > &server_info=std::nullopt) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_audio_block(MCPProtocolVersion version, JSON::StringView data, JSON::StringView mime_type, const MCPResourceAnnotations &annotations={}) -> JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_result_type(const JSON &result) -> std::optional< JSON::StringView >
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_empty_response(const MCPProtocolVersion version, const sourcemeta::core::JSON &identifier, const std::optional< MCPImplementation > &server_info=std::nullopt) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_resource_templates_list_result(const MCPProtocolVersion version, sourcemeta::core::JSON resource_templates, const std::optional< JSON::StringView > next_cursor, const MCPCachePolicy &cache_policy) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_resource(const MCPProtocolVersion version, const JSON::StringView uri, const JSON::StringView name, const JSON::StringView mime_type, const JSON::StringView description={}, const std::optional< std::size_t > size=std::nullopt, const std::optional< double > priority=std::nullopt, const MCPDescriptorPresentation &presentation={}, const MCPResourceAnnotations &annotations={}) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_resolve_result_type(MCPProtocolVersion version, const JSON &result, std::span< const JSON::StringView > supported_extension_types={}) -> std::optional< JSON::StringView >
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_server_discover_response(const MCPProtocolVersion version, const sourcemeta::core::JSON &identifier, const MCPServerCapabilities &capabilities, const MCPImplementation &server, const std::span< const JSON::StringView > supported_versions, const JSON::StringView instructions, const MCPCachePolicy &cache_policy) -> sourcemeta::core::JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_serialize_resource_annotations(MCPProtocolVersion version, const MCPResourceAnnotations &annotations) -> JSON
SOURCEMETA_CORE_MCP_EXPORT auto mcp_make_embedded_resource(MCPProtocolVersion version, JSON resource, const MCPResourceAnnotations &annotations={}) -> JSON
@ Public
Public caching is permissible across multiple clients/users.
Definition mcp_results.h:30
@ Private
Definition mcp_results.h:33