# Tafla for agents

An agent that has worked out a number can hand Tafla the calculation and get back a link to a walkthrough of it: the givens, each step with its formula, talked through in captions or a voice. The calculation stays live, so the reader can drag an input and watch every step recalculate. Tafla's engine computes every value from the formulas the agent sent, so the agent also gets its arithmetic checked.

It is one tool on an MCP server at `https://www.tafla.is/api/mcp`. The agent signs in as the user, the way any app connects to an account: add the server, approve it once in the browser, done. The calculations it creates are shared like the ones the user shares themselves, under their limits, and they keep working for whoever opens them, with no AI behind them.

This file is the plain-text version of https://www.tafla.is/agents, for an agent that fetched the page and got an empty shell. The page renders in the browser.

## Claude Code

Install the plugin once, for every project. It carries the server and a skill that tells Claude when to reach for Tafla (when the user asks to see, explain, share or check a calculation). The plugin is the public repo [hoddmachine/tafla-plugin](https://github.com/hoddmachine/tafla-plugin), and the skill is its [SKILL.md](https://github.com/hoddmachine/tafla-plugin/blob/main/plugins/tafla/skills/tafla/SKILL.md), readable on its own by any agent that wants the rules without the plugin:

```sh
claude plugin marketplace add hoddmachine/tafla-plugin
claude plugin install tafla@tafla
```

Then sign in. The browser opens on Tafla, the user signs in if they aren't, and approves:

```sh
claude mcp login plugin:tafla:tafla
```

The same sign-in is in the session under `/mcp`: pick tafla and choose to authenticate. Claude Code 2.1 or later has the login command; `claude update` brings an older one up.

Things to expect along the way:

- Claude Code may ask the user to approve adding the server or running the sign-in. That is its normal permission check, not a failure; say yes and it carries on.
- MCP servers load when a session starts, so the session that installed the server does not see the tool. A new session does. To answer in the same conversation, Claude can run the call from a fresh headless session instead: `claude -p --allowedTools <the tool's name> "<the calculation>"` and relay the link it returns.
- The sign-in command needs a terminal on its input. In a session without one, run it inside a pseudo-terminal: `script -q /dev/null claude mcp login plugin:tafla:tafla < /dev/null` (macOS and Linux).

After that, once Claude has done some math, ask for the walkthrough: "walk me through that in Tafla". Claude posts the link, and quotes the values the engine computed.

Without the plugin, the server alone is one line, and then the same sign-in with `tafla` as the name:

```sh
claude mcp add --transport http tafla https://www.tafla.is/api/mcp --scope user
claude mcp login tafla
```

## Other hosts

Any host that speaks MCP over HTTP with OAuth can use the same address. In Claude.ai, add it under Settings, Connectors, as a custom connector, and connect. Cursor and other editors take it in their MCP settings:

```json
{
  "mcpServers": {
    "tafla": { "type": "http", "url": "https://www.tafla.is/api/mcp" }
  }
}
```

Each host connects on its own, and the user disconnects one from that host's own settings. Tafla never sees a password: the host gets a token for the account from the sign-in, and that is all it holds.

## The tool

`explain_calculation` takes the question as a title, the givens as inputs, and every derived quantity as a formula over earlier names. Tafla rebuilds the model, writes the walkthrough itself from the labels and descriptions, and answers with the link and the engine's value for every variable. A formula the engine cannot evaluate comes back as an error, and nothing is created until it is fixed.

The rules are the same ones Tafla's own agent works under. An input is a given, never a number the agent computed. A formula shows its mechanism, so the financial wrappers (PMT, FV, PV, NPER) are refused and their closed forms go in as named steps. Rates are the number a person says, 6 for 6%, divided by 100 inside the formulas that use them. Four to ten cards explain better than twenty, and a good label and description on each is what the walkthrough is written from.

A call for a mortgage payment:

```json
{
  "title": "What's the monthly payment on a $250,000 mortgage at 6% over 30 years?",
  "inputs": [
    { "name": "loan_amount", "value": 250000, "unit": "USD", "label": "Loan amount",
      "description": "The amount borrowed.", "min": 0, "max": 1000000, "step": 10000 },
    { "name": "annual_rate", "value": 6, "unit": "%", "label": "Annual rate",
      "min": 0, "max": 15, "step": 0.25 },
    { "name": "years", "value": 30, "unit": "years", "label": "Term",
      "min": 1, "max": 40, "step": 1 }
  ],
  "formulas": [
    { "name": "monthly_rate", "expression": "=annual_rate/12", "unit": "% per month",
      "label": "Monthly rate", "description": "The annual rate spread over 12 months." },
    { "name": "num_payments", "expression": "=years*12", "label": "Number of payments" },
    { "name": "growth_factor", "expression": "=(1+monthly_rate/100)^num_payments",
      "label": "Growth factor", "description": "What one unit grows to over every payment." },
    { "name": "monthly_payment",
      "expression": "=loan_amount*(monthly_rate/100)*growth_factor/(growth_factor-1)",
      "unit": "USD", "label": "Monthly payment",
      "description": "Sized so the balance reaches zero at the end of the term." }
  ]
}
```

The reply carries the walkthrough's link and the computed values, here a monthly payment of $1,498.88, as text for the host and as structured content beside it.

## What it costs, and the limits

Writing the walkthrough is one short model call, counted against the user's account like a share's, and a calculation can be created a few times a day even once they are at their limit. They count against the daily share cap. Voice is made the first time someone opens the link and plays a line, under the listener's own limits, and kept for the next listener. A calculation nobody opens costs nothing more.
