|
|
void | destructor () |
| | Destructor - closes the connection.
|
| |
|
string | getUrl () |
| | Returns the server URL.
|
| |
| bool | isInitialized () |
| | Checks if the client is initialized.
|
| |
| soft< string > | getProtocolVersion () |
| | Gets the negotiated protocol version.
|
| |
| soft< hash< auto > > | getServerInfo () |
| | Gets server information.
|
| |
| soft< hash< auto > > | getServerCapabilities () |
| | Gets server capabilities.
|
| |
| bool | ping () |
| | Sends a ping request to check server health.
|
| |
| list< auto > | listTools () |
| | Lists available tools from the server.
|
| |
| list< auto > | listResources () |
| | Lists available resources from the server.
|
| |
| hash< auto > | readResource (string uri) |
| | Reads a resource from the server.
|
| |
| list< auto > | listPrompts () |
| | Lists available prompts from the server.
|
| |
| hash< auto > | getPrompt (string name, soft< hash< auto > > arguments) |
| | Gets a prompt from the server.
|
| |
| hash< auto > | complete (hash< auto > ref, hash< auto > argument) |
| | Requests completion suggestions.
|
| |
| void | setLogLevel (string level) |
| | Sets the server log level.
|
| |
| void | setCallback (string event, code callback) |
| | Registers an event callback.
|
| |
| void | removeCallback (string event) |
| | Removes an event callback.
|
| |
| void | startSseListener () |
| | Starts the SSE listener for server notifications.
|
| |
|
void | stopSseListener () |
| | Stops the SSE listener.
|
| |
| bool | isSseListenerRunning () |
| | Checks if SSE listener is running.
|
| |
|
void | startLegacySseListener () |
| | Starts the legacy SSE listener.
|
| |
|
void | stopLegacySseListener () |
| | Stops the legacy SSE listener.
|
| |
|
bool | startStreamableListener () |
| | Starts the streamable HTTP GET listener.
|
| |
|
void | stopStreamableListener () |
| | Stops the streamable HTTP GET listener.
|
| |
|
soft< HttpStreamClient::HTTPResponseStream > | openStreamableGet () |
| | Opens a streamable HTTP GET event stream.
|
| |
|
void | streamableEventLoop () |
| | Streamable GET event loop.
|
| |
|
void | close () |
| | Closes the MCP connection.
|
| |
| soft< string > | getSessionId () |
| | Gets the session ID.
|
| |
|
void | setSessionId (string sid) |
| | Sets the session ID (used internally)
|
| |
|
void | ensureInitialized () |
| | Internal: Ensures the client is initialized.
|
| |
|
int | getNextRequestId () |
| | Internal: Gets the next request ID.
|
| |
|
hash< auto > | sendRequest (string method, soft< hash< auto > > params) |
| | Internal: Sends a JSON-RPC request with streamable HTTP, falling back to legacy.
|
| |
|
hash< auto > | sendRequestLegacy (string method, soft< hash< auto > > params) |
| | Internal: Sends a JSON-RPC request using legacy HTTP transport.
|
| |
|
hash< auto > | sendRequestStreamable (string method, soft< hash< auto > > params) |
| | Internal: Sends a JSON-RPC request using streamable HTTP.
|
| |
|
hash< auto > | readStreamableJsonResponse (HttpStreamClient::HTTPResponseStream stream) |
| | Internal: Reads a streamable JSON response.
|
| |
|
hash< auto > | readStreamableSseResponse (HttpStreamClient::HTTPResponseStream stream, int request_id) |
| | Internal: Reads a streamable SSE response and returns the matching response.
|
| |
|
soft< hash< auto > > | handleStreamableMessage (auto msg, int request_id) |
| | Internal: Handles parsed streamable message payloads.
|
| |
|
string | readStreamableBody (HttpStreamClient::HTTPResponseStream stream) |
| | Internal: Reads remaining stream body into a string.
|
| |
|
void | sendNotification (string method, soft< hash< auto > > params) |
| | Internal: Sends a JSON-RPC notification (no response expected)
|
| |
|
void | invokeCallback (string event, soft< list< auto > > args) |
| | Internal: Invokes an event callback.
|
| |
|
void | handleSseConnected () |
| | Internal: Handles SSE connection events.
|
| |
|
void | handleSseClosed () |
| | Internal: Handles SSE disconnection events.
|
| |
|
void | update (string event_id, hash< auto > data_) |
| | Observer callback for SSE client events.
|
| |
|
void | handleNotification (hash< auto > message) |
| | Internal: Handles a server notification.
|
| |
|
void | logDebug (string fmt) |
| | Internal: Logs a debug message.
|
| |
MCP Client class for connecting to MCP servers.
This class provides a client implementation for the Model Context Protocol (MCP). It allows connecting to MCP servers over HTTP with JSON-RPC 2.0 protocol.
- Example:
McpClient client(
"http://localhost:8080/mcp");
# Initialize connection
hash<auto> info = client.initialize({
"name": "MyApp",
"version": "1.0",
});
# Call a tool
hash<auto> result = client.callTool("echo", {"message": "Hello"});
client.close();
the McpClient namespace holds all public definitions in the McpClient module
Definition McpClient.qc.dox.h:2