9#include <QtCore/QJsonObject>
10#include <QtCore/QString>
11#include <QtCore/QStringList>
21 std::optional<QString>
url;
35 Client(QString
url, QString token, std::optional<QString> expectedExecutable);
50 QJsonObject
request(
const QString &method,
const QJsonObject ¶ms);
58 std::optional<QJsonValue>
body;
63 Answer post(
const QJsonObject &message,
const QByteArray &session = { });
An MCP client of the server at a URL, whose session is remembered between runs in a per-user director...
Definition client.h:30
QString m_url
See url().
Definition client.h:71
Answer post(const QJsonObject &message, const QByteArray &session={ })
POSTs message in session (if any); fails if there was no answer, or the server wants a token.
Definition client.cpp:176
QString m_token
The bearer token, or empty.
Definition client.h:72
Http m_http
Makes the requests.
Definition client.h:75
void checkExecutable(const QByteArray &session)
Fails if the server is another build's copy than the expected one.
Definition client.cpp:248
QByteArray newSession()
Starts a session, and remembers it.
Definition client.cpp:219
int m_timeoutMs
See setTimeoutMs().
Definition client.h:73
void setTimeoutMs(int ms)
Gives up on an answer after ms (default: a little over five minutes, for tool calls that wait); shell...
Definition client.h:42
QJsonObject request(const QString &method, const QJsonObject ¶ms)
Sends JSON-RPC method with params in the remembered session, or a new one; fails on an error.
Definition client.cpp:270
QString url() const
The server's URL.
Definition client.h:38
QString sessionFile() const
The file the session's id is kept in (its directory created).
Definition client.cpp:161
Client(QString url, QString token, std::optional< QString > expectedExecutable)
A client of url, sending token if it isn't empty.
Definition client.cpp:154
std::optional< QString > m_expectedExecutable
The executable the server must be.
Definition client.h:74
Makes HTTP requests and waits for each answer, with no proxy and no redirects.
Definition http.h:33
Client clientFrom(const Options &options)
The client sonde uses with options: –url, $SONDE_URL, this checkout's endpoint.json,...
Definition client.cpp:136
void toolsCommand(const Options &options, const QString &command, const QStringList &rest)
sonde tools, describe, call and session, with the arguments after the command in rest.
Definition client.cpp:296
const CommandDoc * command(const QString &name)
The command called name, or nullptr.
Definition commands.cpp:314
Plain HTTP requests, made one at a time and waited for, as sonde makes them.
An answer to a POST: its status, session and body (JSON, text or nothing).
Definition client.h:55
QByteArray session
The Mcp-Session-Id header.
Definition client.h:57
int status
The HTTP status.
Definition client.h:56
std::optional< QJsonValue > body
The body: an object, a string, or nothing.
Definition client.h:58
The options given before the command.
Definition client.h:19
std::optional< QString > token
--token, if given.
Definition client.h:22
std::optional< QString > url
--url, if given.
Definition client.h:21
QString image
--image, or empty.
Definition client.h:23
QString config
--config, or empty.
Definition client.h:20