Open History to see the last commit
1---
2id: ToolRegistry
3title: ToolRegistry
4---
5
6Defined in: [packages/ai/src/tool-registry.ts:9](https://github.com/TanStack/ai/blob/main/packages/ai/src/tool-registry.ts#L9)
7
8A registry that holds tools and allows dynamic tool management.
9
10The registry can be either mutable (allowing additions/removals during execution)
11or frozen (static tool list, for backward compatibility with tools arrays).
12
13## Type Parameters
14
15### TTool
16
17`TTool` *extends* [`AnyTool`](../type-aliases/AnyTool.md) = [`AnyTool`](../type-aliases/AnyTool.md)
18
19## Properties
20
21### add
22
23```ts
24add: (tool) => void;
25```
26
27Defined in: [packages/ai/src/tool-registry.ts:22](https://github.com/TanStack/ai/blob/main/packages/ai/src/tool-registry.ts#L22)
28
29Add a tool to the registry dynamically.
30For frozen registries, this is a no-op.
31
32#### Parameters
33
34##### tool
35
36`TTool`
37
38The tool to add
39
40#### Returns
41
42`void`
43
44***
45
46### get
47
48```ts
49get: (name) => TTool | undefined;
50```
51
52Defined in: [packages/ai/src/tool-registry.ts:46](https://github.com/TanStack/ai/blob/main/packages/ai/src/tool-registry.ts#L46)
53
54Get a tool by name.
55
56#### Parameters
57
58##### name
59
60`string`
61
62The name of the tool to get
63
64#### Returns
65
66`TTool` \| `undefined`
67
68The tool if found, undefined otherwise
69
70***
71
72### getTools
73
74```ts
75getTools: () => TTool[];
76```
77
78Defined in: [packages/ai/src/tool-registry.ts:14](https://github.com/TanStack/ai/blob/main/packages/ai/src/tool-registry.ts#L14)
79
80Get all current tools in the registry.
81Called each agent loop iteration to get the latest tool list.
82
83#### Returns
84
85`TTool`[]
86
87***
88
89### has
90
91```ts
92has: (name) => boolean;
93```
94
95Defined in: [packages/ai/src/tool-registry.ts:38](https://github.com/TanStack/ai/blob/main/packages/ai/src/tool-registry.ts#L38)
96
97Check if a tool exists in the registry.
98
99#### Parameters
100
101##### name
102
103`string`
104
105The name of the tool to check
106
107#### Returns
108
109`boolean`
110
111***
112
113### isFrozen
114
115```ts
116readonly isFrozen: boolean;
117```
118
119Defined in: [packages/ai/src/tool-registry.ts:52](https://github.com/TanStack/ai/blob/main/packages/ai/src/tool-registry.ts#L52)
120
121Whether this registry is frozen (immutable).
122Frozen registries don't allow add/remove operations.
123
124***
125
126### remove
127
128```ts
129remove: (name) => boolean;
130```
131
132Defined in: [packages/ai/src/tool-registry.ts:31](https://github.com/TanStack/ai/blob/main/packages/ai/src/tool-registry.ts#L31)
133
134Remove a tool from the registry by name.
135For frozen registries, this always returns false.
136
137#### Parameters
138
139##### name
140
141`string`
142
143The name of the tool to remove
144
145#### Returns
146
147`boolean`
148
149true if the tool was removed, false if not found or frozen