Guides

An agent's first purchase through MCP

Connect an agent to Abazi's MCP server with its credential, find a service, buy it with one tool call and handle a payment, an approval or a denial.

View as .mdUpdated
One tool call. Every rail. The agent asks for a service; Abazi quotes it, decides under the owner's mandate, pays on whichever rail and network the mandate allows, and hands back the resource with a receipt.

What you end up with

An agent in an MCP client that can buy a paid data service in one call and gets back three things: the data it asked for, a receipt id it can show the owner, and, when it may not buy, a reason code that says what to do next. The agent never holds a wallet key, a card number or its own limits.

Before you start

You needWhy
An agent created in the Console (Agents > New agent), with its credentialThe credential identifies the agent. It carries no spending power on its own.
A signed mandate for that agentWithout one, every purchase is denied with MANDATE_MISSING. See Write a mandate.
Funds on an allowed networkA capped delegation on Solana, or a funded spending wallet on another network.

Steps

Connect the agent

Abazi's MCP server speaks streamable HTTP at https://api.52-28-238-205.sslip.io/mcp. The agent sends its credential as a Bearer token on every request. Clients that only start local processes reach it over stdio through the mcp-remote bridge. In Claude Code it is one command:

Terminal
claude mcp add --transport http abazi https://api.52-28-238-205.sslip.io/mcp --header "Authorization: Bearer $ABAZI_AGENT_KEY"

Clients that take a JSON configuration, such as Cursor, use a URL and a header:

mcp.json
{
  "mcpServers": {
    "abazi": {
      "url": "https://api.52-28-238-205.sslip.io/mcp",
      "headers": { "Authorization": "Bearer YOUR_AGENT_KEY" }
    }
  }
}

Set ABAZI_AGENT_KEY to your agent credential, and replace YOUR_AGENT_KEY with it in JSON configurations: create one in the Console under Agents > New agent (shown once).

Exact setup for each client is in Agents and harnesses: Claude Code, Claude Desktop, Cursor and any MCP client.

The agent now sees six tools. None of them signs, moves funds outside a purchase or changes rules.

ToolWhat it doesInputs (required in bold)
search_catalogFind paid services you can buy, with price, networks and merchant trust tier. Use before request_purchase when you don't know the service_id. Does not spend money.query, category, max_price_base_units, limit
request_purchaseBuy one paid resource by service_id or url. The gateway checks your spending rules, pays, and returns the resource. Use a new idempotency_key per purchase; reuse it to retry the same purchase. Never retry a denial.service_id, url, task_id, idempotency_key, input, purpose, wait_seconds
request_installment_purchaseStart an installment plan (for example 4 x 0.30 USDC) from a merchant's published plan. Always needs owner approval of the total. Use only for plans, not single purchases.plan_id, task_id, idempotency_key
get_purchase_statusCheck a purchase you started: payment status and delivery status are separate. Use after awaiting_approval or submitted, waiting poll_after_ms between calls.intent_id
get_spending_statusYour own budget: available, reserved and spent, plus your per-purchase limits and when your rules expire. Use when a purchase was denied for budget.—
get_receiptGet a signed receipt and its public verification link. Use to prove a purchase happened.receipt_id

Transports: stdio; streamable-http at https://api.52-28-238-205.sslip.io/mcp with Authorization: Bearer YOUR_AGENT_KEY (an agent credential).

Find a service

The agent calls search_catalog with a query. Each result carries a service id, the merchant and its trust tier, the price in base units, the asset and the networks. Searching spends nothing.

search_catalog result
{
  "services": [
    {
      "service_id": "svc_...",
      "name": "Weather forecast",
      "merchant": "Forecast Co",
      "tier": "VERIFIED",
      "price_base_units": "50000",
      "asset": "USDC",
      "chains": ["solana:...", "eip155:..."]
    }
  ]
}

An agent can also buy from a URL that is not in the Catalog. If the URL answers with a valid x402 402 response, Abazi adds the merchant as UNKNOWN and the unknown-merchant limit applies.

Ask to buy

The agent calls request_purchase with the service id (or a URL), a task id and a fresh idempotency key. It does not send a price, an address or a network: Abazi takes those from the Catalog and the mandate.

request_purchase arguments
{ "service_id": "svc_...", "task_id": "trip-plan-7", "idempotency_key": "trip-plan-7-forecast-1" }

Reusing the same key with the same request returns the same purchase, so a retry after a dropped connection never pays twice. Reusing it with a different request is refused.

Read the result

The call waits up to 20 seconds by default for the payment to settle, then returns one of three shapes.

Paid
{
  "status": "paid",
  "intent_id": "pi_...",
  "decision": "ALLOW",
  "reason_code": "WITHIN_POLICY",
  "receipt_id": "rcpt_...",
  "amount_base_units": "50000",
  "asset": "USDC",
  "network": "solana:...",
  "rail": "x402",
  "merchant": { "name": "Forecast Co", "tier": "VERIFIED" },
  "resource": { "content_type": "application/json", "body": "{\"city\":\"Tbilisi\",\"high_c\":14}" }
}

If the payment has not settled within the wait, status is submitted with a hint to poll after two seconds.

Show the receipt

The agent calls get_receipt with the receipt id. It gets the signed receipt and a public verification link that anyone can open without an account. See Verify a receipt.

MCP connection page
MCP and SDKs: how an agent connects with its credential.Captured 2026-11-16

What the agent should do with each outcome

OutcomeAgent action
paidUse the resource; keep the receipt id.
submittedPoll get_purchase_status after the suggested delay.
awaiting_approvalPoll with the same intent; tell the user a person is deciding.
Denied, retryable: trueWait and try later, for example after KILL_SWITCH_ACTIVE is lifted.
Denied, retryable: falseStop and report the reason code and next action.

Every code and its next action is in the reason code reference.

Failure cases

SituationResult
The credential is wrong, rotated or revokedDenied with AGENT_CREDENTIAL_INVALID.
The budget left is too smallDenied with BUDGET_EXCEEDED; get_spending_status shows what is left.
No allowed network is fundedDenied with NO_FUNDED_CHAIN, with the candidate networks in the error.
The merchant's 402 asks for a different payout addressDenied with PAYTO_MISMATCH.

Next steps

On this page