Class McpClientExperimental

A minimal, hand-rolled MCP client for honua-server's POST /mcp Streamable HTTP transport — see the module doc for the SDK-vs-hand-rolled decision. One instance owns one session (Mcp-Session-Id); call McpClient.initialize once before McpClient.listTools / McpClient.callTool (both call it lazily on first use if it hasn't run yet, so callers that only need callTool don't have to sequence it themselves).

Constructors

Accessors

Methods

  • Experimental

    Walks tools/list to completion, following nextCursor until the server stops issuing one, and returns every descriptor in server order.

    The loop is bounded twice, because "follow the cursor until it stops" is an unbounded instruction handed to a remote party:

    • Page cap (McpListAllToolsOptions.maxPages, default MCP_DEFAULT_MAX_TOOL_LIST_PAGES) — a server that keeps issuing fresh cursors forever cannot spin this client forever.
    • Repeat-cursor guard — a server that hands back a cursor it already handed back is looping; that is caught on the first repeat instead of burning the whole page budget on the same page.

    Both bounds throw McpProtocolError rather than silently returning a truncated catalog, because a partial tool catalog is indistinguishable from a narrower server authorization and must never be mistaken for one.

    Neither bound helps against a server that accepts a page request and never answers it, so McpListAllToolsOptions.signal is threaded into the handshake and every page — that is the only bound on a request in flight.

    Parameters

    Returns Promise<McpToolListing>

  • Experimental

    Drops the negotiated Mcp-Session-Id and initialize result so the next call re-handshakes. Callers use this to reconnect — a new server session may advertise a different tool catalog, so whoever calls this is responsible for invalidating anything derived from the old one (StudioAgentSession.reconnect invalidates its tool catalog here).

    Returns void

  • Experimental

    Subscribes to the server's standalone GET /mcp SSE stream and reports every server-initiated notification — notifications/tools/list_changed above all — until the subscription is closed, the server declines the channel, or the reconnect budget runs out.

    The returned stream reads this client's session id on every connect attempt, so a resetSession plus re-handshake is carried automatically. Call this only after (or alongside) a request that has established a session: an un-handshaken client sends no Mcp-Session-Id, which a session-enforcing server rejects.

    Nothing else on this client starts a stream — a consumer that never calls this never opens one.

    Parameters

    Returns McpNotificationStream