|
cxxmcp 1.1.6
C++ MCP SDK
|
Typed annotations for content blocks, tool definitions, and other protocol objects. More...
#include <cmath>#include <optional>#include <string>#include <vector>#include "cxxmcp/core/result.hpp"#include "cxxmcp/protocol/types.hpp"Go to the source code of this file.
Classes | |
| struct | mcp::protocol::Annotations |
| Typed representation of MCP annotations. More... | |
| struct | mcp::protocol::ToolAnnotations |
| Typed representation of MCP tool annotations. More... | |
Functions | |
| Json | mcp::protocol::tool_annotations_to_json (const ToolAnnotations &annotations) |
| Serializes a ToolAnnotations struct to JSON. | |
| core::Result< ToolAnnotations > | mcp::protocol::tool_annotations_from_json (const Json &json) |
| Parses a ToolAnnotations struct from JSON. | |
| Json | mcp::protocol::annotations_to_json (const Annotations &annotations) |
| Serializes an Annotations struct to JSON. | |
| core::Result< Annotations > | mcp::protocol::annotations_from_json (const Json &json) |
| Parses an Annotations struct from JSON. | |
Typed annotations for content blocks, tool definitions, and other protocol objects.
The MCP protocol uses annotations to carry optional presentation hints (audience, priority, timestamps) on resources, content blocks, and tool definitions. This header provides a strongly-typed C++ struct that mirrors the reference rmcp::Annotations model while preserving unknown JSON fields through a raw member for forward compatibility.
Existing DTOs (ContentBlock, ToolDefinition, ...) keep their opaque Json annotations field unchanged. Users who want typed access can round-trip through the free functions declared here.
|
inline |
Parses an Annotations struct from JSON.
Returns an error when:
json is not an objectaudience is present but is not an array of stringspriority is present but is not a number or is outside [0.0, 1.0]lastModified is present but is not a string
|
inline |
Serializes an Annotations struct to JSON.
Known fields (audience, priority, lastModified) are written with their camelCase wire names. Members stored in raw are merged after the typed fields, without overwriting them.