UNPKG

@tanstack/ai-mcp

Version:

Host-side Model Context Protocol client for TanStack AI: discover and run MCP server tools, resources, and prompts in any adapter's chat() loop, with generated end-to-end types.

47 lines (43 loc) • 1.52 kB
export class MCPConnectionError extends Error { constructor( message: string, public override readonly cause?: unknown, ) { super(message) this.name = 'MCPConnectionError' } } export class DuplicateToolNameError extends Error { constructor(public readonly toolName: string) { super( `Duplicate MCP tool name "${toolName}". Set a unique \`prefix\` on one of the ` + `MCP clients (createMCPClient({ transport, prefix: '...' })) to disambiguate.`, ) this.name = 'DuplicateToolNameError' } } /** * Thrown when a task-required tool is explicitly bound via `mcp.tools([...])` * or called via `callTool()` but the server does not declare the tasks * capability for tools/call, so the call could never execute. * (Auto-discovery silently skips such tools.) */ export class MCPTaskRequiredToolError extends Error { constructor(public readonly toolName: string) { super( `MCP tool "${toolName}" requires task-based execution, but the server ` + `does not declare the tasks capability for tools/call`, ) this.name = 'MCPTaskRequiredToolError' } } export class MCPToolNotFoundError extends Error { constructor(public readonly toolName: string) { super( `toolDefinition name "${toolName}" was passed to mcp.tools([...]) but the MCP ` + `server exposes no tool with that name, or the client's \`toolFilter\` hides it. ` + `Check the name or run mcp.tools() to list.`, ) this.name = 'MCPToolNotFoundError' } }