Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
anonymous_namespace{main.cpp}::Client Class Referenceabstract

An MCP client that checks what comes back (invariants 2 and 3). More...

Inheritance diagram for anonymous_namespace{main.cpp}::Client:
anonymous_namespace{main.cpp}::HttpClient anonymous_namespace{main.cpp}::LocalClient

Public Member Functions

 Client (Verdict *verdict, QElapsedTimer *clock)
 Reports violations to verdict, timing requests with clock.
virtual bool connected () const =0
 Whether it can still send.
virtual QString kind () const =0
 The transport's name, for the log.
int send (const QString &method, const QJsonObject &params={ }, const QString &tool={ })
 Sends a request; returns its id.
void notify (const QString &method, const QJsonObject &params={ })
 Sends a notification.
void cancel (int id)
 Cancels request id, if it is still pending.
QList< int > pendingIds () const
 Ids still waiting for an answer.
void checkTimeouts () const
 Fails the verdict for requests unanswered past the timeout (cancelled ones aside).
bool settled () const
 Whether everything not cancelled has been answered.
virtual void disconnectNow ()
 Drops the connection: pending requests are forgotten (no answer is owed).
QStringList takeTexts ()
 The texts of the last results, for harvesting ids and window titles.

Public Attributes

QJsonArray tools
 The last tools/list result.
int results = 0
 tools/call results received.
int toolErrors = 0
 Of those, the ones with isError.

Protected Member Functions

virtual void transmit (const QJsonObject &message, int id)=0
 Sends message; id is its request id, or -1 for a notification.
void fail (const QString &what) const
 Records a violation.
void forget (int id)
 Forgets request id: its answer will never come, and none is owed.
void handle (const QByteArray &bytes)
 Checks one message from the server.

Static Protected Member Functions

static QJsonObject initializeParams ()
 The initialize request's parameters.

Private Attributes

QHash< int, Pending > m_pending
 Requests awaiting an answer.
QStringList m_texts
 Text results not yet taken.
int m_nextId = 1
 Next request id.
Verdict * m_verdict
 Where violations go.
QElapsedTimer * m_clock
 The run's clock.

Detailed Description

An MCP client that checks what comes back (invariants 2 and 3).

Subclasses carry the messages: the local socket, or HTTP.

Member Function Documentation

◆ connected()

virtual bool anonymous_namespace{main.cpp}::Client::connected ( ) const
pure virtual

◆ disconnectNow()

virtual void anonymous_namespace{main.cpp}::Client::disconnectNow ( )
inlinevirtual

Drops the connection: pending requests are forgotten (no answer is owed).

Reimplemented in anonymous_namespace{main.cpp}::HttpClient, and anonymous_namespace{main.cpp}::LocalClient.

◆ kind()

virtual QString anonymous_namespace{main.cpp}::Client::kind ( ) const
pure virtual

The transport's name, for the log.

Implemented in anonymous_namespace{main.cpp}::HttpClient, and anonymous_namespace{main.cpp}::LocalClient.

◆ transmit()

virtual void anonymous_namespace{main.cpp}::Client::transmit ( const QJsonObject & message,
int id )
protectedpure virtual

Sends message; id is its request id, or -1 for a notification.

Implemented in anonymous_namespace{main.cpp}::HttpClient, and anonymous_namespace{main.cpp}::LocalClient.


The documentation for this class was generated from the following file:
  • tests/chaos/main.cpp