9#include <QtCore/QByteArray>
10#include <QtCore/QDateTime>
11#include <QtCore/QJsonArray>
12#include <QtCore/QJsonObject>
13#include <QtCore/QJsonValue>
14#include <QtCore/QSharedDataPointer>
15#include <QtCore/QString>
65 QJsonObject
toJson()
const;
98 static ToolResult image(
const QByteArray &data,
const QString &mimeType);
119 QJsonObject
toJson()
const;
122 QSharedDataPointer<ToolResultData>
d;
150 QString toolName()
const;
152 QJsonObject arguments()
const;
154 QString sessionId()
const;
157 bool isFinished()
const;
159 bool isCancelled()
const;
170 void reportProgress(
double progress,
double total = -1,
const QString &message = { })
const;
174 void onCancelled(std::function<
void()> callback)
const;
180 QObject *context()
const;
183 friend class ServerPrivate;
185 explicit ToolCall(std::shared_ptr<ToolCallPrivate> state) :
d(std::move(state)) { }
186 std::shared_ptr<ToolCallPrivate>
d;
208 QJsonObject
toJson()
const;
221 const QString &
mimeType = QStringLiteral(
"text/plain"));
245 QJsonObject
toJson()
const;
An embeddable Model Context Protocol server.
Definition server.h:92
What every Sonde header includes: the version, and the deprecation macros (design 0031).
Embeddable Model Context Protocol server for Qt applications.
Definition dispatch.cpp:10
std::function< ResourceContents(const QString &uri)> ResourceReader
Produces a resource's contents when a client reads it.
Definition types.h:227
std::optional< LogLevel > logLevelFromName(QStringView name)
Parses an MCP level name (case-insensitive).
Definition types.cpp:22
QString logLevelName(LogLevel level)
The MCP wire name of level, e.g. "warning".
Definition types.cpp:17
std::function< ToolResult(const QJsonObject &arguments)> ToolHandler
Handler of a synchronous tool: arguments in, result out.
Definition types.h:190
LogLevel
MCP (RFC 5424) log levels, from lowest to highest severity.
Definition types.h:31
@ Warning
Warning conditions.
Definition types.h:35
@ Notice
Normal but significant events.
Definition types.h:34
@ Critical
Critical conditions.
Definition types.h:37
@ Info
General informational messages.
Definition types.h:33
@ Emergency
The system is unusable.
Definition types.h:39
@ Debug
Detailed debugging information.
Definition types.h:32
@ Alert
Action must be taken immediately.
Definition types.h:38
std::function< void(const ToolCall &call)> AsyncToolHandler
Handler of an asynchronous tool; answer via ToolCall::finish().
Definition types.h:192
QStringList logLevelNames()
All level names, lowest severity first.
Definition types.cpp:33
Why something failed.
Definition expected.h:42
One entry of an event stream (see EventSource).
Definition types.h:235
QJsonObject toJson() const
The event as JSON (used for log notifications).
Definition types.cpp:184
QString toLine() const
The event as text: "#seq time level source[category]: message {data}".
Definition types.cpp:200
QJsonObject data
Extra source-specific fields.
Definition types.h:242
QString source
EventSource::name() of the producer.
Definition types.h:238
QDateTime timestamp
When the event happened.
Definition types.h:237
QString category
Optional sub-category, e.g. a Qt logging category.
Definition types.h:240
LogLevel level
Severity.
Definition types.h:239
quint64 sequence
Assigned by the server; increases monotonically.
Definition types.h:236
QString message
Human-readable message.
Definition types.h:241
Contents returned by a ResourceReader: text or binary data.
Definition types.h:213
QString text
Text contents, used when !isBinary.
Definition types.h:215
bool isBinary
Whether blob rather than text holds the contents.
Definition types.h:217
static ResourceContents fromText(const QString &text, const QString &mimeType=QStringLiteral("text/plain"))
Text contents.
Definition types.cpp:165
QByteArray blob
Raw bytes, used when isBinary (base64-encoded on the wire).
Definition types.h:216
QString mimeType
MIME type; empty falls back to the definition's.
Definition types.h:214
static ResourceContents fromBlob(const QByteArray &data, const QString &mimeType)
Binary contents.
Definition types.cpp:173
Describes a resource as advertised in resources/list.
Definition types.h:200
QJsonObject toJson() const
The definition as a resources/list entry.
Definition types.cpp:152
QString uri
Unique URI, e.g. "app://config".
Definition types.h:201
QString description
Optional description.
Definition types.h:204
QString name
Short name; defaults to the URI.
Definition types.h:202
QString mimeType
Default MIME type of the contents.
Definition types.h:205
QString title
Optional human-readable title.
Definition types.h:203