Skip to content

McpClient

Defined in: src/mcp.ts:17

MCP Client for interacting with Model Context Protocol servers.

new McpClient(args): McpClient;

Defined in: src/mcp.ts:24

ParameterType
argsMcpClientConfig

McpClient

get client(): Client;

Defined in: src/mcp.ts:35

Client

connect(reconnect?): Promise<void>;

Defined in: src/mcp.ts:46

Connects the MCP client to the server.

This function is exposed to allow consumers to connect manually, but will be called lazily before any operations that require a connection.

ParameterTypeDefault value
reconnectbooleanfalse

Promise<void>

A promise that resolves when the connection is established.


disconnect(): Promise<void>;

Defined in: src/mcp.ts:66

Disconnects the MCP client from the server and cleans up resources.

Promise<void>

A promise that resolves when the disconnection is complete.


listTools(): Promise<McpTool[]>;

Defined in: src/mcp.ts:78

Lists the tools available on the server and returns them as executable McpTool instances.

Promise<McpTool[]>

A promise that resolves with an array of McpTool instances.


callTool(tool, args): Promise<JSONValue>;

Defined in: src/mcp.ts:100

Invoke a tool on the connected MCP server using an McpTool instance.

ParameterTypeDescription
toolMcpToolThe McpTool instance to invoke.
argsJSONValueThe arguments to pass to the tool.

Promise<JSONValue>

A promise that resolves with the result of the tool invocation.