MCPClient handles communication with MCP servers and tool execution
desiredEnabled: boolean
Sets the desired enabled state and triggers connection/disconnection
desiredEnabled: boolean
Gets the desired enabled state
status: McpClientStatus
tools: Tool[]
Gets all tools managed by this client
Disposes of the client and cleans up all resources Should be called when the client is no longer needed
executeToolCall(toolCall: { name: string; input: Record<string, unknown>; }): Promise<CallToolResult>
Executes a tool call and returns the result
waitForConnection(timeout?: number): Promise<void>
Waits for the client to complete the full connection sequence
This method waits for the entire connection process to complete, including:
- Establishing connection to the MCP server
- Discovering and registering available tools (reaches connected.toolDiscovered state)
The connection sequence has substates:
- connected.initial: Just connected, tool discovery not yet started
- connected.toolDiscovered: Full connection complete, tools discovered and ready
Note: This method requires desiredEnabled to be set to true first. If desiredEnabled is false, this method will throw immediately rather than wait. If desiredEnabled is changed to false while waiting, the method will throw.