Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
dispatch.cpp File Reference

ServerPrivate's JSON-RPC dispatch: requests and notifications, initialize, tools/call with argument validation, resources, and the published catalog. More...

#include "server_p.h"
#include <QtCore/QJsonDocument>
#include <cmath>

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.
namespace  Sonde::JsonRpc
 JSON-RPC 2.0 message helpers.

Functions

static const QStringList & Sonde::supportedProtocolVersions ()
 Protocol versions this server speaks, newest first.
QJsonObject Sonde::JsonRpc::result (const QJsonValue &id, const QJsonValue &result)
 A success response.
QJsonObject Sonde::JsonRpc::error (const QJsonValue &id, int code, const QString &message, const QJsonValue &data={ })
 An error response (a missing id becomes null).
QJsonObject Sonde::JsonRpc::notification (const QString &method, const QJsonObject &params)
 A notification; params are omitted when empty.
bool Sonde::JsonRpc::isRequest (const QJsonObject &message)
 Whether message is a request (has both method and id).
bool Sonde::JsonRpc::expectsResponse (const QJsonObject &message)
 Whether message must be answered: it has an id and is not itself a response.
static QString Sonde::requestKey (const QJsonValue &id)
 A JSON-RPC id serialized for use as a hash key.
static bool Sonde::isWholeNumber (double d)
 Whether d is a whole number.
static bool Sonde::hasSchemaType (const QJsonValue &v, const QString &type)
 Whether v is a JSON value of JSON Schema type type.
static QString Sonde::unknownArgument (const QJsonObject &schema, const QJsonObject &args)
 The first argument the schema doesn't list, as an error message, or an empty string.
static QString Sonde::checkArgument (const QString &name, const QJsonValue &v, const QJsonObject &prop)
 Checks one argument against its property schema (type and enum).
static QString Sonde::validateArguments (const QJsonObject &schema, const QJsonObject &args)
 Minimal JSON Schema check: unknown arguments, required properties, and the type and enum of each argument.

Detailed Description

ServerPrivate's JSON-RPC dispatch: requests and notifications, initialize, tools/call with argument validation, resources, and the published catalog.