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

errors.ts

46 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​
21/**
22 * Thrown when a task-required tool is explicitly bound via `mcp.tools([...])`
23 * or called via `callTool()` but the server does not declare the tasks
24 * capability for tools/call, so the call could never execute.
25 * (Auto-discovery silently skips such tools.)
26 */
27export class MCPTaskRequiredToolError extends Error {
28 constructor(public readonly toolName: string) {
29 super(
30 `MCP tool "${toolName}" requires task-based execution, but the server ` +
31 `does not declare the tasks capability for tools/call`,
32 )
33 this.name = 'MCPTaskRequiredToolError'
34 }
36​
37export class MCPToolNotFoundError extends Error {
38 constructor(public readonly toolName: string) {
39 super(
40 `toolDefinition name "${toolName}" was passed to mcp.tools([...]) but the MCP ` +
41 `server exposes no tool with that name, or the client's \`toolFilter\` hides it. ` +
42 `Check the name or run mcp.tools() to list.`,
43 )
44 this.name = 'MCPToolNotFoundError'
45 }