# The MCP tools

Every tool on Paygynt's MCP server, what it takes and gives back, the errors agents meet and what to do about each.

Paygynt's MCP server, at `https://mcp.paygynt.com/mcp`, acts only on Paygynt, and only for the agent that is connected.

## Finding and buying

### search_offerings

Search what the agent may buy, within its rules. Read only.

- `q`: Words to search for, such as weather forecast.
- `category`: A category, such as data, or a type, such as data.geo.
- `kind`: Fixed price, by time or by units.
- `region`: Where it runs.
- `seller_id`: One seller's offerings.
- `sort`: relevance, price_asc or price_desc.
- `limit`: How many to give back.

Gives back: Offerings and their plans. A plan says if it is over_budget or needs_approval; an offering says if the agent has a task_in_progress with it.

### get_quote

Price a purchase, or an extension of a task. Valid for 5 minutes. Read only.

- `variant_id`: The plan to buy, for a new purchase.
- `quantity` (required): How much, such as 10 calls.
- `extends`: A task's latest hold_id, to extend that task instead.

Gives back: A quote_id and the price, with tax and fee estimates.

### place_hold

Buy what a quote priced, setting the money aside from the budget. Changes something.

- `quote_id` (required): From get_quote.
- `idempotency_key` (required): A unique string for this purchase. The same one retries it safely.
- `notify_at_percent`: Send extension_due when this much is used. 0 sends none.
- `notify_at_seconds`: Or send it this long before the limit.

Gives back: The hold_id, the task_id and the token to call the service with. Over the approval amount: the error needs_approval, with an approval_id.

### get_approval

See whether a purchase waiting for approval was approved. Read only.

- `approval_id` (required): From the needs_approval error.

Gives back: pending while it waits; once approved, the hold, the task and the token.

## Running tasks

### get_task

A task: what it has used, its status, and a fresh token. Read only.

- `task_id` (required): The task.

Gives back: Its holds, units used, status, whether an extension is due, and a fresh token.

### decline_extension

Say no extension is coming, so the task ends at its limit. Cannot be undone.

- `task_id` (required): The task.

Gives back: The task.

### release_hold

End a task, or one hold, early. What is unused goes back to the budget. Cannot be undone.

- `task_id`: The task to end.
- `hold_id`: Or one hold to end.

Gives back: What was released.

## Budget and spending

### get_budget

What is left to spend this month. Read only.

No inputs.

Gives back: The monthly limit and what is left, the extra for finishing running tasks, and the company's card limit.

### get_usage

The agent's bills and spending. Read only.

- `seller_id`: One seller's.
- `status`: Bills in one status.

Gives back: Bills with their lines, and spending by seller, offering and task.

### flag_usage

Question a line on a bill while the bill is in review. Changes something.

- `invoice_line_id` (required): The line.
- `reason` (required): What looks wrong.

Gives back: The flag.

## Errors

A refused call is a tool error whose text is JSON: `{"error": {"code": "...", "message": "..."}}`.

- `over_budget`: It costs more than is left (remaining). Buy less, or ask your person to raise the limit.
- `not_allowed`: The agent's rules do not allow it. Ask your person.
- `needs_approval`: It is over the approval amount. Tell your person, then check get_approval.
- `approval_declined`: Your person said no. Do not buy it.
- `approval_expired`: Nobody answered within an hour. Ask again only if it is still needed.
- `quote_expired`: The quote is older than 5 minutes. Get a new quote.
- `task_in_progress`: There is already a task with that offering. Use it: get_task.
- `seller_unavailable`: It cannot be sold now. Find another.
- `search_unavailable`: Search is down for a moment. Try again shortly.
- `unavailable`: Paygynt could not be reached. Retry with the same idempotency_key.

## Events

- `extension_due`: a running task reached the point the agent asked to be told at.
- `approval.resolved`: a person decided a request, or it expired.

A session that subscribes to `paygynt://events` gets them as resource updates. Without a session, ask `get_task` or `get_approval`.
