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

ChatMCPOptions.md

83 lines1.9 KB

1---
2id: ChatMCPOptions
3title: ChatMCPOptions
4---
5​
6# Interface: ChatMCPOptions
7​
8Defined in: [packages/ai/src/activities/chat/mcp/types.ts:55](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/mcp/types.ts#L55)
9​
10Options controlling MCP tool discovery and lifecycle for a `chat()` call.
11​
12## Properties
13​
14### clients
15​
16```ts
17clients: MCPToolSource[];
18```
19​
20Defined in: [packages/ai/src/activities/chat/mcp/types.ts:59](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/mcp/types.ts#L59)
21​
22The MCP clients or client pools to discover tools from and manage.
23​
24***
25​
26### connection?
27​
28```ts
29optional connection: MCPConnectionPolicy;
30```
31​
32Defined in: [packages/ai/src/activities/chat/mcp/types.ts:66](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/mcp/types.ts#L66)
33​
34Connection lifecycle policy applied to all clients when the run ends.
35​
36Defaults to `'close'`.
37​
38***
39​
40### lazyTools?
41​
42```ts
43optional lazyTools: boolean;
44```
45​
46Defined in: [packages/ai/src/activities/chat/mcp/types.ts:74](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/mcp/types.ts#L74)
47​
48When `true`, tool schemas are fetched lazily (forwarded to
49`tools({ lazy: true })`).
50​
51Defaults to `false`.
52​
53***
54​
55### onDiscoveryError()?
56​
57```ts
58optional onDiscoveryError: (error, source) => void | Promise<void>;
59```
60​
61Defined in: [packages/ai/src/activities/chat/mcp/types.ts:85](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/mcp/types.ts#L85)
62​
63Called when tool discovery fails for a single source.
64​
65- Throw (or re-throw) from this handler to fail the entire chat call fast.
66- Return normally to skip that source and continue with remaining clients.
67- Omit this handler entirely to rethrow the error (fail-fast by default).
68​
69Async handlers are awaited, so a rejected promise also fails fast.
70​
71#### Parameters
72​
73##### error
74​
75`unknown`
76​
77##### source
78​
79[`MCPToolSource`](MCPToolSource.md)
80​
81#### Returns
82​
83`void` \| `Promise`\<`void`\>