import { InferToolInput, InferToolOutput } from '@tanstack/ai'; import { MCPServer } from './server/create-server.js'; import { MCPResourceContext } from './server/definitions.js'; type Named = { name: string; }; type ToolNames> = TTools[number]['name']; type ToolByName, TName extends string> = Extract; type ResourceUris> = Extract['uri']; type PromptNames> = TPrompts[number]['name']; type PromptByName, TName extends string> = Extract; type ResourceContents = TResource extends { read: (...args: never) => infer TResult; } ? Awaited : never; type PromptArgs = TPrompt extends { render: (input: infer TArgs) => unknown; } ? TArgs : never; type PromptMessages = TPrompt extends { render: (input: never) => infer TResult; } ? Awaited : never; /** * The client types of a `createMCPServer` server, for a client that * connects over a transport. * * Pass `typeof server` to `createMCPClient` with a `transport`. * Import the server with `import type`, so its code stays out of the client. * * @example * ```ts * import type { server } from './mcp-server.js' * * const client = await createMCPClient({ * transport: { type: 'http', url: 'https://mcp.example.com/mcp' }, * }) * await client.callTool('get_weather', { city: 'Paris' }) * ``` */ export type DescriptorFromServer = { tools: { [TTool in TServer['tools'][number] as TTool['name']]: { input: InferToolInput; output: InferToolOutput; }; }; resources: { [TResource in Extract as TResource['uri']]: { uri: TResource['uri']; data: ResourceContents; }; }; prompts: { [TPrompt in TServer['prompts'][number] as TPrompt['name']]: { args: PromptArgs; messages: PromptMessages; }; }; capabilities: Record; }; /** * Calls the tools, resources, and prompts on one TanStack MCP server. * * `server` is the object from `createMCPServer`. * The tool names, resource URIs, and prompt arguments stay typed. * This client does not open a network connection. * `callTool` checks `args` with the tool input schema and parses the output * with its output schema, like the HTTP server. * The tool gets the spec 2026 context: `ctx.context.requestInput` throws * `ToolInputRequiredError`, and `ctx.context.sample` uses the server * `sample` option. * * @param server - The server object to call * * @example * ```ts * const client = directMCPClient(server) * await client.callTool('get_weather', { city: 'Paris' }) * ``` */ export declare function directMCPClient(server: TServer): { server: TServer; callTool>(name: TName, args: InferToolInput>, options?: { signal?: AbortSignal; }): Promise>>; /** * Reads a resource with a fixed `uri`. `context` reaches the resource * on `ctx.context`. It is empty when you leave it out. */ readResource>(uri: TUri, context?: MCPResourceContext["context"]): Promise>>; getPrompt>(name: TName, args: PromptArgs>): Promise>>; }; export type DirectMCPClient = ReturnType>; export type DirectClientOptions = { server: TServer; }; export {};