mcp-server

v0.12.0
@spendctl/mcp-server Checked 3 days ago Published 4 hours ago

MCP server exposing spendctl to agents: pay, await_approval, withdraw_approval, check_budget, list_receipts.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

pay Fetch a paid URL

Fetches an HTTP(S) URL that may require payment (HTTP 402: x402 or MPP) through the local spendctl sidecar, which applies the human's budget, allowlist and approval policy, pays if allowed and returns the response. Use it for any URL that might charge; a free URL behaves like a normal fetch. Use dryRun to learn the decision without paying, and the same idempotencyKey when retrying so nothing is paid twice. Returns a one-line summary (HTTP status, amount paid, decision, receipt id, and the Idempotency-Key or X-Request-Id you sent, if any) followed by the response body (clipped at 20,000 charact…

ParameterTypeDescription
url *stringAbsolute http(s) URL, e.g. https://api.example.com/v1/weather?city=Kyoto
approvalIdstringThe approval id from an earlier held pay result, once await_approval reports it approved, to complete that payment
bodystringRequest body for POST/PUT/PATCH
dryRunbooleantrue: only report what spendctl would decide; never pay
headersobjectExtra request headers, e.g. {"accept": "application/json"}
idempotencyKeystringReuse the same key when retrying a call so you are never charged twice, e.g. "order-42"
methodstringHTTP method, default GET

await_approval Wait for a held payment's decision

Waits for a human to decide a payment that pay reported as held (Approval id: apr_…), without paying again. Long-polls the sidecar for up to timeoutSeconds (default 20, at most 25; keep it under your client's tool timeout) and returns the approval's status: pending (call again), approved (repeat pay with approvalId to complete the payment), denied, expired or withdrawn (this agent took it back with withdraw_approval). Only this agent's own approvals are visible and no admin token is involved. Read-only: it never pays and never decides.

ParameterTypeDescription
approvalId *stringThe approval id from a held pay result, e.g. "apr_mvxjidauzqzag9"
timeoutSecondsintegerHow long to wait for a decision before answering pending (1 to 25, default 20)

withdraw_approval Withdraw a held payment the task no longer needs

Takes back a payment that pay reported as held (Approval id: apr_…) when the task that needed it was cancelled or superseded, so a late human approval cannot pay for it. Nothing is paid: the approval and its ledger entry close as withdrawn (distinct from a human's denial), a later `spendctl approve` on that id is refused, and await_approval on it answers withdrawn at once. Only this agent's own pending approvals can be withdrawn, with the agent's identity and no admin token. If the payment is needed after all, a new pay call opens a fresh approval. Withdrawing an id that was already decided…

ParameterTypeDescription
approvalId *stringThe approval id from a held pay result, e.g. "apr_mvxjidauzqzag9"
notestringOptional reason recorded with the withdrawal, e.g. "task cancelled by the user"

check_budget Check remaining budget

Shows this agent's spending limits, what has been spent in each window and what is left. Use it before a large or repeated spend, or after a refusal to see which limit was hit. Returns the agent name and mode, the per-request limit, the approval threshold, what happens when a budget is exceeded, the allowed hosts and one line per window (hourly, daily: spent, limit, remaining). Read-only; changes nothing.

list_receipts List receipts

Lists this agent's most recent payment attempts, newest first: paid (amount and transaction hash), refused (reason codes) and waiting for approval. Use it to report what was paid or to find the approval id a human needs. Returns up to `limit` lines, one per attempt, with time, receipt id, method, host and path, amount and status, plus the Idempotency-Key and X-Request-Id the request carried, if any, or "No payments yet." Read-only.

ParameterTypeDescription
limitintegerHow many attempts to return, newest first (1 to 100, default 10)