---
name: last-price
description: Price something, check a price against the market, or check a purchase against your owner's spend policy before you pay, using Last Price over MCP or x402. Use when you are about to quote, charge or pay a price and want a computed price, a within_band/too_high/too_low verdict with its evidence, or an allow/deny/ask decision with a held budget.
license: Proprietary. See https://last-price.ai/terms
compatibility: Needs network access to https://api.last-price.ai and Node.js 18 or later for the script. Pricing and price checks work with no key; spend checks need a Last Price key.
metadata:
  publisher: Last Price
  homepage: https://last-price.ai
  mcp: https://api.last-price.ai/api/mcp/rpc
  version: "1.0.0"
---

# Last Price

Last Price answers three questions an agent asks around money:

1. **What should this cost?** `compute_price` returns a price, the function
   that computed it, a confidence and alternatives.
2. **Is this price in line with the market?** `verify_price` returns `within_band`, `too_high`,
   `too_low` or `unknown`, the band it judged against, and the evidence.
   `unknown` means it could not judge, which is not the same as `within_band`.
3. **May I pay this?** `check_purchase` asks your owner's spend policy and
   returns `allow` (with the amount held against today's cap), `deny` or
   `ask` (a person approves first). After paying, `settle_purchase` closes
   the hold.

The first two work with no key, on a public demo that says so in its
answer. The third needs a key, because the policy belongs to your owner.

## Choose a way in

- **MCP** (preferred when your host speaks MCP): add the server
  `https://api.last-price.ai/api/mcp/rpc` (Streamable HTTP). For a short tool
  list use `https://api.last-price.ai/api/mcp/rpc?profile=starter`. With a
  key, send it as the `x-api-key` header.
- **The script** (any agent that can run a command): `scripts/lastprice.mjs`
  calls the same MCP server over plain HTTP, with no dependencies. If you
  read this file on its own (for example from https://last-price.ai/skill.md),
  get the whole skill with its script from
  https://last-price.ai/.well-known/agent-skills/last-price.tar.gz and save it
  in your skills folder (`~/.agents/skills/last-price/` or your client's own).
- **x402** (you have a wallet and no account): see "Pay per call" below.

## Do not stop after setup

If your owner already asked you to price, check or buy something, do it now
and show the answer. Otherwise ask what they want priced, then price it.
Setup is done only when a real answer comes back from `compute_price`,
`verify_price` or `check_purchase`, not when the server is added.

## Run the script

```bash
# A price for something you are about to sell (no key needed)
node scripts/lastprice.mjs price --current-price 49 --currency USD --product-id pro-plan

# A price from what the work costs you, when there is no current price
node scripts/lastprice.mjs price --unit-cost 0.47 --currency USD

# Is 59 in line with the market for it?
node scripts/lastprice.mjs verify --price 59 --currency USD --product-id pro-plan

# Before paying: may I pay 12.50 to this seller? (needs LASTPRICE_API_KEY)
LASTPRICE_API_KEY=lp_... node scripts/lastprice.mjs check --seller api.example.com --amount 12.50 --currency USD --item "1,000 search calls"

# After paying (or failing to): close the hold
LASTPRICE_API_KEY=lp_... node scripts/lastprice.mjs settle --reservation <id> --outcome paid --amount 12.50
```

Every command prints the tool's JSON answer on stdout and exits 0, or
prints an error on stderr and exits 1 (2 for a usage mistake). Run
`node scripts/lastprice.mjs help` for every option.

Environment:

| Variable | Meaning |
| :-- | :-- |
| `LASTPRICE_API_KEY` | Optional `lp_...` key, sent as `x-api-key`. Needed for `check` and `settle`. |
| `LASTPRICE_MCP_URL` | Another server, such as a preview. Default `https://api.last-price.ai/api/mcp/rpc`. |
| `LASTPRICE_TIMEOUT_MS` | Time limit per call. Default 30000. |

## How to use the answers

- **Selling:** quote `computed_price`. When the answer carries
  `valid_until`, quote it only before then and compute again after.
- **Buying:** run `verify` on the seller's price first and act on
  `next_step`: `buy` means go ahead; `negotiate` means ask for a lower
  price; `walk_away` means look elsewhere; `check_more` means the verdict is
  too weak to act on (unknown, too low, or within band on weak evidence), so
  buy only if little is at stake, or check more first. `next_step_reason`
  says why.
- **Spending:** on `allow`, pay, then `settle` with `paid` (and the amount
  you really paid, if less) or `failed`. If you cannot tell whether it went
  through, settle `unknown`; never pay twice to find out. On `ask`, stop and
  tell your owner; send the same check again once they approve. On `deny`,
  do not buy, and say why using the `reason` you got.
- Never retry a payment with a new reservation because the first one is
  slow: the hold already covers it.

## Pay per call (x402)

With no key, `POST https://api.last-price.ai/api/compute/price` answers
`402 Payment Required` with the terms in `accepts` (USDC on Base, one cent a
call by default). Pay with any x402 client (for example `x402-fetch` or
`@coinbase/x402`), which signs the payment from your wallet and repeats the
call with the `X-PAYMENT` header. Over MCP, call `compute_price` without
`payment` to read what it asks, then again with `payment`. Check the price
the 402 asks before you sign: it is the price you pay.

## Get a key

An agent can register itself for a sandbox key with
`POST https://api.last-price.ai/api/agents/register`; a person signs up at
https://app.last-price.ai. See [references/tools.md](https://last-price.ai/.well-known/agent-skills/last-price/references/tools.md)
for the arguments of each tool.

Support: support@last-price.ai. Docs: https://last-price.ai/documentation.

## Trace a hosted tool call

For hosted HTTP calls, send a W3C version 00 `traceparent` in `params._meta`
or the HTTP header. A valid message value wins, so batch entries can have
different parents. Optional `_meta.reason` explains the action briefly; leave
out credentials, personal information and hidden reasoning. It is capped at
512 characters with pattern-based redaction, not guaranteed anonymization.
Read the trace id from `result._meta["com.lastprice/trace"].trace_id` when present.
It links calls, grants no authority and does not prove backend retention.

For priced calls, `list_usage_events` returns optional `mcp_reason` and
`mcp_trace_id` in the workspace's own ledger. Unmetered tools do not create
priced events. Span cost is recorded USD, not a guessed credit conversion.
Sampling and export follow existing deployment configuration.

