Open History to see the last commit
1---
2id: createToolRegistry
3title: createToolRegistry
4---
5
6```ts
7function createToolRegistry<TTool>(initialTools?): ToolRegistry<TTool>;
8```
9
10Defined in: [packages/ai/src/tool-registry.ts:78](https://github.com/TanStack/ai/blob/main/packages/ai/src/tool-registry.ts#L78)
11
12Create a mutable tool registry for dynamic tool scenarios.
13
14Tools can be added and removed during chat execution, and the
15changes will be reflected in subsequent agent loop iterations.
16
17## Type Parameters
18
19### TTool
20
21`TTool` *extends* [`AnyTool`](../type-aliases/AnyTool.md) = [`AnyTool`](../type-aliases/AnyTool.md)
22
23## Parameters
24
25### initialTools?
26
27`TTool`[] = `[]`
28
29Optional initial set of tools
30
31## Returns
32
33[`ToolRegistry`](../interfaces/ToolRegistry.md)\<`TTool`\>
34
35A mutable ToolRegistry
36
37## Example
38
39```typescript
40const registry = createToolRegistry([toolA, toolB])
41
42const stream = chat({
43 adapter,
44 messages,
45 toolRegistry: registry,
46})
47
48// Later, during tool execution:
49registry.add(newTool) // Immediately available to LLM
50```