Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

errors.ts

42 lines1.5 KB

1export class MCPConnectionError extends Error {
2 constructor(
3 message: string,
4 public override readonly cause?: unknown,
5 ) {
6 super(message)
7 this.name = 'MCPConnectionError'
8 }
9}
10​
11export class DuplicateToolNameError extends Error {
12 constructor(public readonly toolName: string) {
13 super(
14 `Duplicate MCP tool name "${toolName}". Set a unique \`prefix\` on one of the ` +
15 `MCP clients (createMCPClient({ transport, prefix: '...' })) to disambiguate.`,
16 )
17 this.name = 'DuplicateToolNameError'
18 }
20​
21export class MCPTaskRequiredToolError extends Error {
22 constructor(public readonly toolName: string) {
23 super(
24 `MCP tool "${toolName}" declares \`execution.taskSupport: 'required'\` — it can ` +
25 `only be invoked via the MCP SDK's experimental task-based execution ` +
26 `(client.experimental.tasks.callToolStream()), which @tanstack/ai-mcp does not ` +
27 `support yet. Task-required tools are excluded from tools() auto-discovery; ` +
28 `binding one explicitly via tools([toolDefinition(...)]) is an error.`,
29 )
30 this.name = 'MCPTaskRequiredToolError'
31 }
33​
34export class MCPToolNotFoundError extends Error {
35 constructor(public readonly toolName: string) {
36 super(
37 `toolDefinition name "${toolName}" was passed to mcp.tools([...]) but the MCP ` +
38 `server exposes no tool with that name. Check the name or run mcp.tools() to list.`,
39 )
40 this.name = 'MCPToolNotFoundError'
41 }