|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
The result of a tools/call: content blocks, optional structured content, and an error flag. More...
#include <types.h>
Public Member Functions | |
| ToolResult () | |
| An empty, successful result. | |
| ToolResult (const ToolResult &other) | |
Shares other's contents (copied when either changes). | |
| ToolResult & | operator= (const ToolResult &other) |
Shares other's contents (copied when either changes). | |
| ~ToolResult () | |
| Destroys the result. | |
| ToolResult & | addText (const QString &text) |
| Appends a text block. | |
| ToolResult & | addImage (const QByteArray &data, const QString &mimeType) |
| Appends an image block from raw bytes (encoded to base64 here). | |
| ToolResult & | addContent (const QJsonObject &contentBlock) |
| Appends an arbitrary MCP content block (e.g. an embedded resource). | |
| ToolResult & | setStructuredContent (const QJsonObject &object) |
| Sets the structuredContent object. | |
| ToolResult & | setError (bool isError=true) |
| Marks the result as a tool error (or clears the mark). | |
| bool | isError () const |
| Whether the result is marked as an error. | |
| QJsonArray | content () const |
| The content blocks. | |
| QJsonObject | toJson () const |
| The result as a tools/call result object. | |
Static Public Member Functions | |
| static ToolResult | text (const QString &text) |
| A result with a single text block. | |
| static ToolResult | error (const QString &message) |
| A failed result (isError) with an explanatory text block. | |
| static ToolResult | image (const QByteArray &data, const QString &mimeType) |
| A result with a single image block. | |
| static ToolResult | structured (const QJsonObject &object) |
A result whose structuredContent is object, plus the same object serialized as text for clients that ignore structured content. | |
Private Attributes | |
| QSharedDataPointer< ToolResultData > | d |
| Implicitly shared contents. | |
The result of a tools/call: content blocks, optional structured content, and an error flag.
Builder methods return a reference so results can be chained:
|
default |
Shares other's contents (copied when either changes).
There are no move operations on purpose: a move would leave other without contents, and sharing costs only a reference count.
|
static |
A result with a single image block.
| data | Raw (not base64-encoded) image bytes, e.g. PNG data. |
| mimeType | The image type, e.g. "image/png". |