Back to docs

Tools

Zod ships a fully functional client-side function-calling toolbelt. The model can call built-in tools, custom JavaScript tools you write, and MCP server tools — all executed in your browser, with results fed back into the conversation.

The tool loop

When you send a message, Zod calls your provider with all tool schemas. If the model requests tool calls, Zod executes them in the browser and appends the results, repeating up to 6 rounds before streaming the final answer. Tools are dispatched through a shared runAnyTool in this order: custom → MCP → built-in — so custom and MCP tools work identically in chat, the scheduler, and agent steps.

Built-in tools

Nine tools ship with Zod. Each declares a JSON Schema and a runner, wired together so the model always gets accurate call signatures.

Tool Actions What it does
memory read / write / delete / clear Long-term markdown memory blocks (## heading), persists across sessions
todo add / check / uncheck / delete / list Persistent to-do list, persisted as markdown
calculator evaluate Safe arithmetic with a hand-written tokenizer/parser: + - * / % ^, parentheses, sqrt, exp, log/ln, trig, min/max, pi, e
clipboard read / write System clipboard access (requires browser permission)
timer set / list / cancel In-browser reminders that surface as a chat message + browser Notification
code_tools json_format / json_validate / yaml_to_json / json_to_yaml / yaml_format JSON & YAML utilities, including the global-aligned YAML formatter
confirm ask Prompts the user with a yes/no modal before destructive actions
random uuid / dice / number / hash UUIDs, dice rolls, random numbers, WebCrypto hashes
time now / convert / list_timezones Current time, timezone conversions, common IANA zones

Custom tools

Define your own tools in Settings → Tools as YAML with a JavaScript implementation. When the model calls one, the code runs in a sandbox exposing sandbox.args (the tool arguments) and sandbox.ctx (persistent state, fetch, timers, askUser, and memory getters/setters) and returns a string or JSON value back into the loop.

tools:
  - name        : greet
    description : Greet a person by name
    implementation: |
      export default ({ args, ctx }) => {
        return `Hello, ${args.name}!`;
      };

How tool context persists

Tool execution wires persistent state into every call: memory and todos are handed to the tools, changes are saved after every mutation, and the timer registry and the askUser bridge are provided. That state lives in the same localStorage document as everything else, so tools remember across sessions.

Memory

Markdown blocks persisted across sessions

Todos

Persistent to-do list