Interface MCPClient
interface MCPClient {
options: MCPClientOptions;
serverInfo: MCPInitializeResult | null;
url: string;
callTool<
Structured extends Record<string, unknown> = Record<string, unknown>,
>(
name: string,
args?: Record<string, unknown>,
): Promise<MCPToolResult<Structured>>;
initialize(): Promise<MCPInitializeResult>;
listTools(): Promise<MCPToolDefinition[]>;
notify(method: string, params?: Record<string, unknown>): Promise<void>;
ping(): Promise<void>;
request<Result = unknown>(
method: string,
params?: Record<string, unknown>,
): Promise<Result>;
}
options: MCPClientOptions;
serverInfo: MCPInitializeResult | null;
url: string;
callTool<
Structured extends Record<string, unknown> = Record<string, unknown>,
>(
name: string,
args?: Record<string, unknown>,
): Promise<MCPToolResult<Structured>>;
initialize(): Promise<MCPInitializeResult>;
listTools(): Promise<MCPToolDefinition[]>;
notify(method: string, params?: Record<string, unknown>): Promise<void>;
ping(): Promise<void>;
request<Result = unknown>(
method: string,
params?: Record<string, unknown>,
): Promise<Result>;
}
Index
Properties
Methods
Methods
call Tool
- callTool<Structured extends Record<string, unknown> = Record<string, unknown>>(
name: string,
args?: Record<string, unknown>,
): Promise<MCPToolResult<Structured>>Call a tool. A failing tool returns a result with isError set, it doesn't throw
Type Parameters
- Structured extends Record<string, unknown> = Record<string, unknown>
Expected type of the result's structuredContent
Parameters
- name: string
Name of the tool
Optionalargs: Record<string, unknown>Arguments for the tool
Returns Promise<MCPToolResult<Structured>>
- Structured extends Record<string, unknown> = Record<string, unknown>
initialize
Initialize the connection. Must be called before any other requests
Returns Promise<MCPInitializeResult>
list Tools
List the tools offered by the server
Returns Promise<MCPToolDefinition[]>
notify
Send a JSON-RPC notification
Parameters
- method: string
Optionalparams: Record<string, unknown>
Returns Promise<void>
ping
Ping the server
Returns Promise<void>
request
Send a JSON-RPC request and return its result
Type Parameters
- Result = unknown
Parameters
- method: string
Optionalparams: Record<string, unknown>
Returns Promise<Result>
Client for MCP servers using the Streamable HTTP transport. Create one using createMCPClient