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