|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
Minimal MCP client speaking newline-delimited JSON over QLocalSocket. More...
#include <testsupport.h>
Public Member Functions | |
| LocalClient (const QString &name) | |
Connects to the local server name; check isConnected(). | |
| bool | isConnected () const |
| Whether the socket connected. | |
| QJsonObject | request (const QString &method, const QJsonObject ¶ms={ }, int timeoutMs=5000) |
| Sends a request and waits for its response. | |
| int | sendRequest (const QString &method, const QJsonObject ¶ms={ }) |
| Sends a request without waiting; returns the id used. | |
| QJsonObject | waitForResponse (int id, int timeoutMs=5000) |
Waits for the response to request id. | |
| void | notify (const QString &method, const QJsonObject ¶ms={ }) |
| Sends a notification (no id). | |
| void | sendRaw (const QByteArray &data) |
| Writes raw bytes to the socket. | |
| QJsonObject | initialize (const QString &protocolVersion=QStringLiteral("2025-06-18")) |
| Performs initialize + notifications/initialized. | |
| QJsonObject | callTool (const QString &name, const QJsonObject &arguments={ }, int timeoutMs=5000) |
| Calls a tool and returns its result object (empty on JSON-RPC error). | |
| QString | callToolText (const QString &name, const QJsonObject &arguments={ }, int timeoutMs=5000) |
| Calls a tool and returns the concatenated text of its result. | |
| bool | waitForNotification (const QString &method, int timeoutMs=3000, qsizetype from=0) |
Waits until a notification with method arrives (counting from from). | |
| const QList< QJsonObject > & | notifications () const |
| All notifications received so far. | |
| const QList< QJsonArray > & | batches () const |
| Responses that arrived as JSON arrays (legacy batches). | |
| QLocalSocket & | socket () |
| The underlying socket. | |
Private Member Functions | |
| void | onReadyRead () |
| Parses complete lines from the read buffer. | |
Minimal MCP client speaking newline-delimited JSON over QLocalSocket.
Responses are matched by id; everything without an id (notifications) is collected in notifications().
| QJsonObject SondeTest::LocalClient::request | ( | const QString & | method, |
| const QJsonObject & | params = { }, | ||
| int | timeoutMs = 5000 ) |
Sends a request and waits for its response.