---
title: "Recipe: tools an agent or the system calls"
description: "A tool line offers a root action to callers other than the person: Siri and Shortcuts (App Intents) and a browser's agent (WebMCP), if it has a face in app.json."
modificationDate: "2026-11-23"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: tools an agent or the system calls

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/tools: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

A `tool` line offers a root action to callers other than the person: Siri and Shortcuts (App
Intents) and a browser's agent ([WebMCP](https://webmachinelearning.github.io/webmcp/)), if it
has a face in `app.json`.

```prompt Let Siri and agents call my app's actions
Offer actions of the Exact app in this folder as tools that Siri, Shortcuts and a browser's agent can call. Use https://github.com/expo/exact/blob/main/docs/recipes/tools.md as the source for each step. The Exact checkout has the same page at docs/recipes/tools.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. If I did not say which actions to offer, read the root's actions and propose a list: each tool's name, its title, and whether it reads, writes or destroys. Ask me before you write code.
3. In app.contract, write a `tool` line for each root action, as the recipe shows. After the name, write `reads`, `writes` or `destroys`. Then write each of these that is true: `additive` (after `writes` only), `idempotent`, `closed`. Then write a description for the caller.
4. Add the clauses in this order: `returns`, `fails when`, `available when`. A faced tool's `returns` is a string, a number or a bool. `fails when` is read after the action: keep a refusal in a state that the action sets, as the recipe's `lastFailed` does.
5. In app.json, give each tool a face under `intents.tools`: a `title`, and a `title` for each parameter. A tool with no face is not offered to Siri, Shortcuts or a browser's agent. A `destroys` tool's `doors` default to `apple` alone.
6. On the web, a route that says `activate=interaction` registers the tools only when its script starts. Leave `activate=` unsaid on a route where an agent must find the tools after load.
7. Add a test in app.test.contract for each action behind a tool, through the app's controls. `call` is not a test step.
8. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. Then drive each tool as the recipe does (`bun exact.mjs agent web 'call addItem {"name":"Milk","aisle":"dairy","quantity":2}' state`), and read each call's `outcome` in `state.intents`. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 9) and report it; do not keep trying.
9. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
10. Tell me each tool, its face and each call's `outcome`, and what the tests and checks reported. To try the tools in Chrome, I must turn on `chrome://flags/#enable-webmcp-testing` and open the app in a secure context: `https`, `localhost` or `127.0.0.1`.
```

```contract
routes nav
  home "/" render=build

component App
  state items: string[] = []
  state lastFailed = false
  tool listItems reads "The shopping list, one item per line." = listItems
    returns items.join("\n")
  tool addItem writes additive closed "Add an item. Fails for an empty name." = addItem
    returns `${items.length} on the list`
    fails when lastFailed
    available when items.length < 20
  tool clearList destroys "Remove every item." = clearList
    available when items.length > 0
  action listItems
  action addItem(name: string, aisle: enum<"produce", "dairy", "other">, quantity: number)
    let refused = name.trim() == ""
    lastFailed = refused
    if not refused
      items = items.concat([`${quantity} × ${name.trim()} (${aisle})`])
  action clearList
    items = []
  view
    main
      text "Shopping" role="heading" aria-level=1
      for i in items key=i
        text i
```

```json
{ "intents": { "tools": {
  "listItems": { "title": "List Items" },
  "addItem": { "title": "Add Item", "parameters": {
    "name": { "title": "Name" }, "aisle": { "title": "Aisle" },
    "quantity": { "title": "Quantity", "type": "integer" } } },
  "clearList": { "title": "Clear List" } } } }
```

- **After the name:** `reads`, `writes` or `destroys`; then `additive` (after `writes`: adds,
  never overwrites), `idempotent` (a repeat changes nothing), `closed` (touches only
  the app's data).
- **Clauses**, in this order: `returns` (a faced tool's is a string, number or bool, else
  `intents-face-type`), `fails when` (true after the action: `outcome: failed`), `available when`
  (false: a call is refused, `reason: unavailable`; WebMCP also withdraws the tool, an App
  Intent does not). An `enum` outside its list: `reason: arguments`.
- **The face:** a parameter's `entity` names a kind of `intents.entities`. `doors` defaults
  to `apple`, `android` (AppFunctions: not built yet) and `web`; a `destroys` tool's is
  `apple` alone.
- **On the web** a page registers its faced tools with `document.modelContext` once its script
  runs. A route with no `activate=` that would otherwise wait for the reader is `idle` in an app
  with a faced tool on the web door, so the tools are registered after load; a route that says
  `activate=interaction` registers them only when its script starts (the pitfall's triggers).
  `document.modelContext` exists only in a secure context: `https`, `localhost` or `127.0.0.1`,
  not a LAN address over `http`. Chrome: `chrome://flags/#enable-webmcp-testing`, or
  `--enable-features=WebMCP`; without it the page runs as before.
- **Drive:** `bun exact.mjs agent web 'call addItem {"name":"Milk","aisle":"dairy","quantity":2}'
  state`; `state.intents` lists the tools and each call's `outcome`. `call` is not a test step.
