PetaSats

v0.2.24
io.github.BSVanon/petasats-mcp Checked 6 hours ago Published 9 days ago

Buy BSV with USDC on Base through a local non-custodial MCP server.

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

get_quote Get USDC to BSV quote

Get a live quote for buying BSV with USDC on Base. Read-only: nothing is locked or spent. Call it before swap_asset_to_bsv and show the quote to the person directing you; it lasts about 60 seconds, and passing its quote_id to swap_asset_to_bsv uses these terms. Returns quote_id, expires_at, usdc_in, bsv_out, est_bsv_received_sats (after the BSV claim fee), rate_usd_per_bsv, market_mid_usd_per_bsv, price_vs_mid_percent, costs and limits. If the counterparty declines (busy or over a limit), the error carries code, retry_after_s and retry_hint. To send the BSV to another wallet, use fund_wallet:…

ParameterTypeDescription
amount_in *stringUSDC to spend, in atomic units as a decimal string. USDC has 6 decimals: "25000000" = 25 USDC. The quote's limits field gives the current per-swap and daily limits.
from_asset *stringAsset you pay with. Must be "USDC" (USDC on Base).
to_asset *stringAsset you receive. Must be "BSV".

swap_asset_to_bsv Start USDC to BSV swap

Buy BSV with this kit's USDC on Base through a non-custodial atomic swap with the counterparty. This moves funds: it locks USDC on Base, so get a quote with get_quote first and confirm it with the person directing you. Pass quote_id (or the quote object) to use that quote's terms, or min_bsv_out as a floor; if the quote has expired, the kit gets a new one and goes ahead only if it pays at least min_bsv_out, or 99% of the old quote. Returns at once with swap_id, stage, expected_minutes and the settlement mode; then call wait_for_swap until done is true. Refused while another swap is in progress…

ParameterTypeDescription
amount_in *stringUSDC to spend, in atomic units as a decimal string ("25000000" = 25 USDC). Must equal the amount_in of the quote you pass.
from_asset *stringAsset you pay with. Must be "USDC" (USDC on Base).
deliver_tostringOptional BSV mainnet address (P2PKH, starting with 1) to receive the BSV. Without it the BSV stays in this kit (see wallet_info; withdraw_bsv moves it later). With it, the kit sends the claimed BSV th…
min_bsv_outstringOptional floor for the BSV received, in satoshis as a decimal string ("100000000" = 1 BSV). Required when neither quote_id nor quote is given.
quoteobjectOptional: the whole quote object from get_quote, instead of quote_id. Its route, pair and amount_in must match this request.
quote_idstringOptional quote_id from get_quote. Uses that quote's terms while it is valid.
speedstringOptional buyer choice. standard (default) waits for one BSV confirmation. fast reveals the secret against an unconfirmed BSV lock, and applies only when both sides agree and the amount is at most $25.

wait_for_swap Wait for swap update

Wait until a swap's stage changes or it finishes, then return its status. Read-only: it watches this kit's local swap record while the swap runs in the background. After swap_asset_to_bsv, call it repeatedly until swap.done is true; a swap usually finishes within about an hour. Returns changed (false when the wait ended with no change, which is normal: call again), waited_seconds, and swap, the same view swap_status gives: stage, stage_label, step and steps_total, done, outcome (delivered, settled, refunded or failed), eta_minutes and txids with explorer links. Sends progress notifications whe…

ParameterTypeDescription
swap_id *stringThe swap_id returned by swap_asset_to_bsv or listed by swap_status.
max_wait_secondsintegerOptional longest wait in whole seconds, from 1 to 55. Default 50.

swap_status Swap status

Show the status of one swap, or of every swap this kit has made. Read-only and instant: it reads the kit's local swap records and changes nothing. Returns swaps, a list (empty when swap_id is unknown). Each entry has swap_id, stage and stage_label, step and steps_total, done, outcome (delivered, settled, refunded or failed), usdc_in, bsv_quoted, bsv_received once settled, deliver_to, eta_minutes, deadlines, txids with explorer links, needs_attention and what_to_do. To wait for the next change, use wait_for_swap rather than calling this in a loop.

ParameterTypeDescription
swap_idstringOptional swap_id from swap_asset_to_bsv. Omit it to list every swap this kit has made.

wallet_info Wallet information

Show this kit's own wallets: the Base address that pays for swaps, the BSV address that receives them, their balances, and whether spending is stopped. Read-only; never returns key material. Call it first: if the kit has no USDC, tell the user to send it to baseAddress. ETH for Base gas is optional: the user can send a little, or, after their yes, buy_gas buys it with 0.50 USDC. Returns baseAddress, bsvAddress, usdc and eth balances in atomic units, claimedBsvSats, unconfirmedBsvSats (BSV received but not confirmed yet), capUsdPerSwap, spending_stopped (with stopped_at and stop_reason), the li…

stop_spending Stop spending

Emergency stop: block new swaps and withdrawals from this kit until the user runs `npx petasats-mcp resume` in a terminal; no tool can resume it. Use it when the user asks, or when something looks wrong. A swap already started still completes or refunds. Idempotent: calling it again keeps the first stop. Returns stopped: true, at (milliseconds since 1970) and reason, plus already_stopped: true when a stop was already in place.

ParameterTypeDescription
reasonstringOptional note stored with the stop, up to 200 characters; wallet_info shows it as stop_reason.

withdraw_bsv Withdraw all confirmed BSV

Send all of this kit's confirmed BSV to one BSV address. This moves funds and cannot be undone: use only an address the user gave you, and confirm it with them first. It always sends the whole confirmed balance, and the network fee comes out of it; there is no partial amount. Refused while a swap or a BSV delivery is in progress, while spending is stopped, or when limits.json does not allow the address. Returns txid and sats sent, or sats 0 with a reason when there is no confirmed BSV. Use withdraw_base for USDC or ETH; to send a new swap's BSV straight to an address, pass deliver_to to swap_a…

ParameterTypeDescription
address *stringDestination BSV mainnet address (P2PKH, starting with 1), supplied and confirmed by the user.

withdraw_base Withdraw Base funds

Send USDC or ETH from this kit's Base wallet to another Base address. This moves funds and cannot be undone: use only an address the user gave you, and confirm it with them first. The kit pays the gas in ETH, so withdraw USDC before ETH. Refused while a swap is in progress, while spending is stopped, or when limits.json does not allow the address. Returns asset, amount (atomic and display), to, txid, status and a BaseScan url. Use withdraw_bsv for BSV.

ParameterTypeDescription
amount *stringAtomic units as a decimal string (USDC has 6 decimals, "1000000" = 1 USDC; ETH is in wei), or "all". For ETH, "all" keeps back the gas and needs the USDC withdrawn first.
asset *stringWhich asset to send: "USDC" or "ETH".
to *stringDestination Base address in checksummed 0x form (EIP-55), supplied and confirmed by the user. Not this kit's own address, and not a swap or token contract.

fund_wallet Plan wallet funding

Plan sending BSV to a specific BSV address, paid with this kit's USDC on Base. Read-only: it returns a live quote and the exact swap_asset_to_bsv call (with deliver_to set), but moves nothing. Use it when the BSV should land in another wallet; use get_quote when it can stay in this kit. Fails if the kit could not start that swap now (spending stopped, address refused by limits.json, or over the daily limit). Returns plan, quote (the get_quote fields; valid about 60 seconds), swap_call and non_custodial.

ParameterTypeDescription
amount_in *stringUSDC to spend, in atomic units as a decimal string ("25000000" = 25 USDC).
bsv_address *stringBSV mainnet address (P2PKH, starting with 1) that should receive the BSV.
from_assetstringOptional asset to pay with; only "USDC" (USDC on Base, the default) is available.

list_liquidity List liquidity

List the trading pairs this kit supports and how each one settles. Read-only and offline: a fixed list with no prices or balances; use get_quote for a live price and wallet_info for balances. Today there is one pair, USDC on Base to BSV, settled by an on-chain atomic swap with the counterparty; PetaSats never holds funds. Returns pairs (each with pair, route and note), count, non_custodial and settlement.

ParameterTypeDescription
assetstringOptional exact symbol, such as "USDC" or "BSV"; returns only the pairs that include it.

close_kit Empty and close the kit

Empty this kit into the user's own wallets, then stop it: it spends nothing more until the user runs `npx petasats-mcp resume` in a terminal. This moves funds and cannot be undone: base_address and bsv_address must be addresses the user gave you and confirmed, never this kit's own addresses. Each call takes at most one step and returns at once; call it again after call_again_after_seconds until state is 'closed'. It refuses while a swap is running, naming the swap, or while spending is already stopped for another reason. It sends USDC first, then BSV, then ETH. Only ETH dust that cannot pay it…

ParameterTypeDescription
base_address *stringDestination Base address in checksummed 0x form (EIP-55), supplied and confirmed by the user. Not this kit's own address.
bsv_address *stringDestination BSV mainnet address (P2PKH, starting with 1), supplied and confirmed by the user. Not this kit's own address.

buy_gas Buy ETH for gas with 0.50 USDC

Buy a little ETH for Base gas with exactly 0.50 USDC from this kit's own balance, so a kit funded with USDC alone can swap and withdraw. This moves the user's funds: call it only after the user says yes, and tell them the 0.50 USDC comes out of their balance. Each yes covers one purchase. It signs one CoW Protocol order that sells 0.50 USDC for ETH paid to this kit's own Base address; a CoW Protocol solver settles it and pays the network fee, so it works with no ETH in the kit. Refused when the kit already has gas (0.00002 ETH or more), holds less than 0.50 USDC, or spending is stopped. While…

pay_402 Pay BSV HTTP 402 API

Pay a BSV pay-per-call API (HTTP 402, BRC-166) from this kit's own BSV. Call with confirm false to see the price first.

ParameterTypeDescription
confirm *booleanfalse previews the exact invoice price without signing; true signs and sends the BRC-166 payment header.
max_sats *stringMaximum invoice amount in satoshis. The kit refuses a higher price and its own caps may be lower.
url *stringHTTPS URL of the BSV pay-per-call API resource.
bodystringOptional request body, sent unchanged on the price check and payment retry.
content_typestringOptional Content-Type for body. Without it, a body is sent as application/json.
methodstringOptional HTTP method. Defaults to GET.