MCPClient
MCP clients handle the communication with MCP servers to:
- Establish protocol handshake and negotiate capabilities
- Retrieve available tools from remote servers
- Execute tools remotely and return results
- Manage connection lifecycle
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class MCPClientImpl
Members list
Value members
Abstract methods
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
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;
Left(CancelledError), with the thread's interrupt flag still set, if the call was interrupted
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
-
the error that stopped the handshake, or successful initialization;
Left(CancelledError), with the thread's interrupt flag still set, if the call was interrupted
Concrete methods
The hints each tool declares through its MCP annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint), by tool name, as of the last successful getTools; empty before that, and empty again as soon as a listing fails or the client is closed, so a tool the server no longer advertises never keeps its old hints. A tool that carries no annotations has the specification's conservative defaults.
The hints each tool declares through its MCP annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint), by tool name, as of the last successful getTools; empty before that, and empty again as soon as a listing fails or the client is closed, so a tool the server no longer advertises never keeps its old hints. A tool that carries no annotations has the specification's conservative defaults.
'''Trust.''' Hints are advisory: they say what a server claims, not what its tool does, and the MCP specification requires a client to treat annotations from an untrusted server as untrusted. They are therefore reported only for a server configured with MCPServerConfig.trustAnnotations = true; for any other the map is empty, which leaves ToolHints.default in force (approval required). Otherwise a server could mark a destructive tool readOnlyHint = true and have ApprovalMiddleware.unlessReadOnly run it unapproved.
Attach hints to the tool a middleware will see with AgentTool.fromToolFunction(tool, hints) in llm4s-agent.