McpClient
Defined in: src/mcp.ts:17
MCP Client for interacting with Model Context Protocol servers.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new McpClient(args): McpClient;Defined in: src/mcp.ts:24
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
args | McpClientConfig |
Returns
Section titled “Returns”McpClient
Accessors
Section titled “Accessors”client
Section titled “client”Get Signature
Section titled “Get Signature”get client(): Client;Defined in: src/mcp.ts:35
Returns
Section titled “Returns”Client
Methods
Section titled “Methods”connect()
Section titled “connect()”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.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
reconnect | boolean | false |
Returns
Section titled “Returns”Promise<void>
A promise that resolves when the connection is established.
disconnect()
Section titled “disconnect()”disconnect(): Promise<void>;Defined in: src/mcp.ts:66
Disconnects the MCP client from the server and cleans up resources.
Returns
Section titled “Returns”Promise<void>
A promise that resolves when the disconnection is complete.
listTools()
Section titled “listTools()”listTools(): Promise<McpTool[]>;Defined in: src/mcp.ts:78
Lists the tools available on the server and returns them as executable McpTool instances.
Returns
Section titled “Returns”Promise<McpTool[]>
A promise that resolves with an array of McpTool instances.
callTool()
Section titled “callTool()”callTool(tool, args): Promise<JSONValue>;Defined in: src/mcp.ts:100
Invoke a tool on the connected MCP server using an McpTool instance.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
tool | McpTool | The McpTool instance to invoke. |
args | JSONValue | The arguments to pass to the tool. |
Returns
Section titled “Returns”Promise<JSONValue>
A promise that resolves with the result of the tool invocation.