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

Helpers for writing the JSON Schemas of tool arguments. More...

#include <sonde/global.h>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonObject>
#include <QtCore/QStringList>

Go to the source code of this file.

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.
namespace  Sonde::Schema
 Builders for tool argument schemas (JSON Schema subsets that the server's argument check understands: type, enum, required).

Enumerations

enum class  Sonde::JsonType {
  Sonde::String , Sonde::Integer , Sonde::Number , Sonde::Boolean ,
  Sonde::Array , Sonde::Object
}
 The JSON Schema types a property may have. More...

Functions

QString Sonde::jsonTypeName (JsonType type)
 The JSON Schema name of type, such as "string".
QJsonObject Sonde::Schema::described (QJsonObject schema, const QString &description)
 schema with "description" set to description, unless that is empty: a description that says nothing (an array's items, say) costs tokens in every session.
QJsonObject Sonde::Schema::property (JsonType type, const QString &description)
 A property of a JSON type.
QJsonObject Sonde::Schema::anyProperty (const QString &description)
 A property of any JSON type.
QJsonObject Sonde::Schema::enumProperty (const QStringList &values, const QString &description)
 A string property restricted to values.
QJsonObject Sonde::Schema::arrayProperty (const QJsonObject &items, const QString &description)
 An array property whose elements match items (an empty object allows anything).
QJsonObject Sonde::Schema::object (const QJsonObject &properties, const QStringList &required={ })
 The schema of a tool's arguments: an object with properties, of which required must be given.

Detailed Description

Helpers for writing the JSON Schemas of tool arguments.

Tool schemas are plain QJsonObjects; these functions only make the common shapes shorter to write and consistent:

def.inputSchema = Schema::object({
{"name", Schema::property(JsonType::String, "Who to greet.")},
{"times", Schema::property(JsonType::Integer, "How often (default 1).")},
{"style", Schema::enumProperty({"plain", "loud"}, "Greeting style (default plain).")},
}, {"name"});