MCPClient | WebHare Platform SDK
WebHare Platform SDK
    Preparing search index...

    Interface MCPClient

    Client for MCP servers using the Streamable HTTP transport. Create one using createMCPClient

    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>;
    }
    Index

    Properties

    serverInfo: MCPInitializeResult | null = null

    Result of initialize(), once called

    url: string

    Methods

    • 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>>

    • Send a JSON-RPC notification

      Parameters

      • method: string
      • Optionalparams: Record<string, unknown>

      Returns Promise<void>

    • Ping the server

      Returns Promise<void>

    • Send a JSON-RPC request and return its result

      Type Parameters

      • Result = unknown

      Parameters

      • method: string
      • Optionalparams: Record<string, unknown>

      Returns Promise<Result>

      MCPProtocolError if the server returns a JSON-RPC error

      MCPHTTPError if the server returns an HTTP error