MCPClientImpl

org.llm4s.mcp.MCPClientImpl
See theMCPClientImpl companion object
class MCPClientImpl(config: MCPServerConfig) extends MCPClient

Implementation of MCP client that connects to and communicates with MCP servers. Handles JSON-RPC communication, tool discovery, and execution delegation. Supports both 2025-06-18 (Streamable HTTP) and 2024-11-05 (HTTP+SSE) transports.

Attributes

Companion
object
Graph
Supertypes
trait MCPClient
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def close(): Unit

Closes the MCP client connection and releases resources. Should be called when done with the client.

Closes the MCP client connection and releases resources. Should be called when done with the client.

Attributes

Definition Classes
override def getTools(): Either[String, Seq[ToolFunction[_, _]]]

Retrieves all available tools from the MCP server. Returns tools converted to the llm4s ToolFunction format.

Retrieves all available tools from the MCP server. Returns tools converted to the llm4s ToolFunction format.

Attributes

Returns

Sequence of tool functions available from this server

Definition Classes
override def initialize(): Either[String, Unit]

Initializes the MCP connection with handshake protocol. Must be called before other operations.

Initializes the MCP connection with handshake protocol. Must be called before other operations.

Attributes

Returns

Either error message or successful initialization

Definition Classes
def trySendingRequest(transportImpl: MCPTransportImpl): Either[String, Seq[ToolFunction[_, _]]]