UNPKG

xmcp

Version:

The TypeScript MCP framework

46 lines (45 loc) • 1.74 kB
import { Client } from "@modelcontextprotocol/client"; import { StdioClientTransport, type StdioServerParameters } from "@modelcontextprotocol/client/stdio"; import type { Buffer } from "node:buffer"; import { CustomHeaders } from "./headers"; export declare const CLIENT_IDENTITY: { name: any; version: any; }; interface HttpClientOptions { /** Full MCP server base URL — example: https://host.tld/mcp */ url: string; headers?: CustomHeaders; } /** * Pure direct HTTP MCP client (no proxy, no SSE, no stdio) */ export declare function createHTTPClient({ url, headers, }: HttpClientOptions): Promise<Client>; export interface StdioClientOptions extends StdioServerParameters { /** * Optional hook that receives stderr chunks when the transport * runs with piped stderr (defaults to logging to console.error). */ onStderrData?: (chunk: Buffer) => void; } export interface StdioClientConnection { client: Client; transport: StdioClientTransport; } /** * Spawn and connect to an MCP server via stdio transport. */ export declare function createSTDIOClient(options: StdioClientOptions): Promise<StdioClientConnection>; /** * Convenience helper to list available tools on a stdio MCP server. */ export declare function listSTDIOClientTools(connection: StdioClientConnection): Promise<string[]>; /** * Invoke a tool exposed by the connected stdio MCP server. */ export declare function callSTDIOClientTool(connection: StdioClientConnection, toolName: string, args: Record<string, unknown>): Promise<unknown>; /** * Disconnect the stdio transport and close the client. */ export declare function disconnectSTDIOClient(connection: StdioClientConnection): Promise<void>; export {};