# serverTool
Source: https://docs.maelstrom-ai.co/dev/reference/engine/functions/servertool/
Documentation revision: 89a8f5e9d10cedcf0b30376d7846113f06f26120
SDK manifests in this build: @maelstrom-co/react@0.2.1, @maelstrom-co/client@0.2.1, @maelstrom-co/connectors@0.2.1, @maelstrom-co/protocol@0.2.1, @maelstrom-co/engine@0.2.1
These docs follow this source revision. Manifest versions do not prove release compatibility; verify the installed package exports before using an API.

> **serverTool**<`Input`, `Output`\>(`definition`): [`ServerTool`](https://docs.maelstrom-ai.co/dev/reference/engine/interfaces/servertool/)<`Input`, `Output`\>

Defined in: [packages/engine/src/lib/agent-session/server-tool.ts:123](https://github.com/maelstrom-co/maelstrom/blob/89a8f5e9d10cedcf0b30376d7846113f06f26120/packages/engine/src/lib/agent-session/server-tool.ts#L123)

Declares a Server Tool, inferring input and output types and applying defaults: `locus` `server`, `sideEffect` `non_idempotent` and `approval` `never`. Register it through the `tools` field of the Engine `agent` config.

> [!WARNING]
> Experimental
> 
> This API should not be used in production and may be trimmed from a public release.

## Type Parameters

### Input

`Input`

### Output

`Output`

## Parameters

### definition

[`ServerToolDefinition`](https://docs.maelstrom-ai.co/dev/reference/engine/type-aliases/servertooldefinition/)<`Input`, `Output`\>

## Returns

[`ServerTool`](https://docs.maelstrom-ai.co/dev/reference/engine/interfaces/servertool/)<`Input`, `Output`\>

## Example

```ts
const latestOrder = serverTool({
  name: 'latest_order',
  description: 'Returns the latest order of the signed-in user',
  input: z.object({}),
  output: z.object({ orderId: z.string() }),
  sideEffect: 'read_only',
  execute: (_input, ctx) => orders.latestFor(ctx.user, ctx.signal),
  summarize: (order) => `Order ${order.orderId}`,
});
```

The agent loop is experimental in 0.3 and may change in any minor release.
