Open History to see the last commit
1---
2id: MCPToolSource
3title: MCPToolSource
4---
5
6# Interface: MCPToolSource
7
8Defined in: [packages/ai/src/activities/chat/mcp/types.ts:25](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/mcp/types.ts#L25)
9
10Minimal structural shape that `chat({ mcp })` needs from an MCP client.
11
12`@tanstack/ai-mcp`'s `MCPClient` and `MCPClients` satisfy this interface by
13shape — the core `@tanstack/ai` package does NOT import `@tanstack/ai-mcp`
14(ai-mcp depends on ai, not the reverse).
15
16## Properties
17
18### close()
19
20```ts
21close: () => Promise<void>;
22```
23
24Defined in: [packages/ai/src/activities/chat/mcp/types.ts:30](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/mcp/types.ts#L30)
25
26#### Returns
27
28`Promise`\<`void`\>
29
30***
31
32### readResource()?
33
34```ts
35optional readResource: (uri) => Promise<McpResourceReadResult>;
36```
37
38Defined in: [packages/ai/src/activities/chat/mcp/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/mcp/types.ts#L38)
39
40Reads an MCP resource by URI. Used by the chat manager to eagerly fetch
41`ui://` resource widgets (MCP Apps) after a tool result resolves.
42
43Optional — sources that do not serve `ui://` resources need not implement
44this method. `ai-mcp`'s `MCPClient` satisfies this structurally.
45
46#### Parameters
47
48##### uri
49
50`string`
51
52#### Returns
53
54`Promise`\<`McpResourceReadResult`\>
55
56***
57
58### tools()
59
60```ts
61tools: (options?) => Promise<ServerTool<SchemaInput, SchemaInput, string, unknown>[]>;
62```
63
64Defined in: [packages/ai/src/activities/chat/mcp/types.ts:29](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/mcp/types.ts#L29)
65
66#### Parameters
67
68##### options?
69
70###### lazy?
71
72`boolean`
73
74#### Returns
75
76`Promise`\<[`ServerTool`](ServerTool.md)\<[`SchemaInput`](../type-aliases/SchemaInput.md), [`SchemaInput`](../type-aliases/SchemaInput.md), `string`, `unknown`\>[]\>