# Metrics

Connect the numbers your decisions are measured by, from your tools, from files, or from a script.

## From your tools

A recipe tells ZeroWidth which read-only calls to make to a tool, and how to turn the answers into daily numbers. Use one of ours, such as Stripe, or write your own. Name each source in zerowidth.json.

```zerowidth.json
"sources": [
  { "id": "stripe", "adapter": "mcp-recipe", "recipe": "stripe", "keyEnv": "STRIPE_API_KEY" },
  { "id": "crm", "adapter": "command", "command": ["node", "crm-adapter.ts"], "env": ["CRM_KEY"] }
]
```

Define the source's metrics once, then let `serve` pull on schedule.

```Terminal
zerowidth metrics --pull --source stripe --define
```

Check a command adapter you write with the same checks we run on ours.

```Terminal
zerowidth adapters check crm
```

A recipe your team writes runs once the source's `approved` setting holds the recipe's hash. `zerowidth adapters show <recipe>` shows what the recipe may call and the hash: read the recipe before approving.

`zerowidth metrics --sources` shows each source: whether a pull is due, when the source last worked, and anything wrong.

## From files

A spreadsheet as CSV or .xlsx, or a dashboard's CSV export. The first run is a dry run that says what each file holds and which decisions the file's metrics could judge.

```Terminal
zerowidth metrics ./kpis.csv
zerowidth metrics ./kpis.csv --run
```

Restart `serve` after the first `--run`.

## From a script or an agent

Once a metric is defined, an agent sends readings with `record_readings`. Self-hosted, metrics are defined from files or with `--define`; hosted, an admin defines metrics in the console. [Record numbers](https://zerowidth.ai/docs/mcp/numbers)
