Open History to see the last commit
1---
2id: mergeAgentTools
3title: mergeAgentTools
4---
5
6# Function: mergeAgentTools()
7
8```ts
9function mergeAgentTools(serverTools, clientTools): Tool<SchemaInput, SchemaInput, string>[];
10```
11
12Defined in: [packages/typescript/ai/src/utilities/chat-params.ts:174](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/utilities/chat-params.ts#L174)
13
14Merge a server-side tool array with the AG-UI client-declared tools
15received in the request body.
16
17Rules:
18- Server tools win on name collision. The client's declaration is
19 ignored if the server already has a tool with that name. The client's
20 UI-side handler still fires when the streamed tool-result event comes
21 through (see `chat-client.ts` `onToolCall`), giving the
22 "after server execution the client also handles" semantic for free.
23- Client-only tools (name not in `serverTools`) become no-execute
24 entries: the runtime's existing `ClientToolRequest` path handles
25 them — server emits a tool-call request, client executes via its
26 registered handler, client posts back the result.
27
28## Parameters
29
30### serverTools
31
32readonly [`Tool`](../interfaces/Tool.md)\<[`SchemaInput`](../type-aliases/SchemaInput.md), [`SchemaInput`](../type-aliases/SchemaInput.md), `string`\>[]
33
34The server's tool array (e.g. from
35 `[myToolDef.server(...)]`). Pass directly to `chat({ tools })`.
36
37### clientTools
38
39readonly `object`[]
40
41The `tools` array received from
42 `chatParamsFromRequest(...)` / `chatParamsFromRequestBody(...)`.
43
44## Returns
45
46[`Tool`](../interfaces/Tool.md)\<[`SchemaInput`](../type-aliases/SchemaInput.md), [`SchemaInput`](../type-aliases/SchemaInput.md), `string`\>[]
47
48A merged array suitable for `chat({ tools })`.