MCPClient implementation that connects to an MCP server over JSON-RPC.
== Transport auto-detection == For HTTP-based server configs (StreamableHTTPTransport or SSETransport), this client first attempts to connect using the MCP 2025-06-18 Streamable HTTP protocol. If the server responds with HTTP 404 or 405, it automatically falls back to the older 2024-11-05 HTTP+SSE protocol. Stdio servers always use the 2024-11-05 protocol.
== Failures in getTools == getTools() returns a Left for any failure during tool discovery (network error, JSON-RPC error, unreadable listing, missing transport), so "the server has no tools" (Right(Seq.empty)) is distinct from "the server could not be reached". An interrupted call returns Left(CancelledError) with the thread's interrupt flag still set (design section 4.4).
== Thread safety == This class is not thread-safe. Concurrent calls to initialize, getTools, or close from different threads require external synchronisation.
Value parameters
- config
-
Server configuration including transport type, URL/command, and timeout.
Attributes
- Companion
- object
- Graph
-
- Supertypes