# Claude Code

Add Abazi's MCP server to Claude Code with one command, check the six tools, and let Claude Code search the catalog and make its first purchase under your mandate.

Claude Code connects to Abazi's MCP server over streamable HTTP. One command registers the server with the agent's credential in a Bearer header. After that, Claude Code can search the catalog, buy, follow a purchase and fetch receipts, and every purchase runs through the owner's mandate.

## Before you start [#before-you-start]

| You need | Why |
| --- | --- |
| An agent credential (`agk_test_...`) | Created in the [Console](https://app.52-28-238-205.sslip.io) under **Agents > New agent**. Shown once. Replace `YOUR_AGENT_KEY` with it. See [Get an agent credential](/docs/agents#get-an-agent-credential). |
| A signed mandate for that agent | Without one every purchase is denied with <ReasonCode code="MANDATE_MISSING" />. |
| Claude Code installed | The `claude` command on your path. |
| MCP URL | `https://api.52-28-238-205.sslip.io/mcp` |

## Connect [#connect]

Put the credential in your shell, then add the server.

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

The shell expands `$ABAZI_AGENT_KEY` when you run the command, so Claude Code stores the credential in your local configuration for this project.

### Share the server with a team [#share-the-server-with-a-team]

`--scope project` writes the server to `.mcp.json` in the project root, which you can commit. Use single quotes so the file keeps the variable name, not the secret. Each person sets `ABAZI_AGENT_KEY` in their own environment, and Claude Code expands it when it starts the server.

```bash title="Terminal"
claude mcp add --transport http --scope project abazi https://api.52-28-238-205.sslip.io/mcp --header 'Authorization: Bearer ${ABAZI_AGENT_KEY}'
```

```json title=".mcp.json"
{
  "mcpServers": {
    "abazi": {
      "type": "http",
      "url": "https://api.52-28-238-205.sslip.io/mcp",
      "headers": { "Authorization": "Bearer ${ABAZI_AGENT_KEY}" }
    }
  }
}
```

## Verify [#verify]

```bash title="Terminal"
claude mcp list
```

`abazi` appears with its URL and a connected status. Inside Claude Code, run `/mcp`: the `abazi` server lists six tools, `search_catalog`, `request_purchase`, `request_installment_purchase`, `get_purchase_status`, `get_spending_status` and `get_receipt`. Claude Code names them `mcp__abazi__search_catalog` and so on.

Then ask for a search. Searching spends nothing.

```text title="Prompt"
Use the abazi tools to search the catalog for "forecast". Show me the service ids and prices.
```

Claude Code calls `search_catalog` and gets back a list like this:

```json title="search_catalog result"
{
  "services": [
    {
      "service_id": "svc_...",
      "name": "Weather forecast",
      "merchant": "Forecast Co",
      "tier": "VERIFIED",
      "price_base_units": "50000",
      "asset": "USDC",
      "chains": ["solana:...", "eip155:..."],
      "description": "Daily forecast for one city"
    }
  ]
}
```

Prices are in base units: USDC has six decimals, so `50000` is 0.05 USDC.

## First purchase [#first-purchase]

```text title="Prompt"
Search the catalog for forecast and buy it for Tbilisi. Use task id trip-plan-7. Then show me the receipt.
```

Claude Code calls `request_purchase` with the `service_id` it found, 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. The call waits up to 20 seconds for the payment to settle.

### ALLOW [#allow]

```json title="request_purchase result"
{
  "status": "paid",
  "intent_id": "pi_...",
  "decision": "ALLOW",
  "reason_code": "WITHIN_POLICY",
  "receipt_id": "rcpt_...",
  "amount_base_units": "50000",
  "asset": "USDC",
  "rail": "x402",
  "merchant": { "name": "Forecast Co", "tier": "VERIFIED" },
  "resource": { "content_type": "application/json", "body": "..." }
}
```

Claude Code then calls `get_receipt` and shows the signed receipt with its public verification link. If the payment is still settling, `status` is `submitted` and Claude Code polls `get_purchase_status` after `poll_after_ms`.

### REQUIRE_APPROVAL [#require_approval]

Above the auto-approve limit, on a first purchase from a merchant, or for an unknown merchant, the result is `awaiting_approval` with a reason such as <ReasonCode code="ABOVE_AUTO_THRESHOLD" /> or <ReasonCode code="FIRST_PURCHASE" />. Abazi sends the approval link to the owner's approvers, not to Claude Code. Claude Code keeps the same `intent_id` and polls `get_purchase_status` every `poll_after_ms` (5 seconds). The link expires after <Limit name="approvalTtl" />. A rejected or expired approval ends as `denied` with <ReasonCode code="APPROVAL_REJECTED" /> or <ReasonCode code="APPROVAL_EXPIRED" />. See [Approve on a phone](/docs/guides/approve-on-a-phone).

### DENY [#deny]

A denial comes back as an error result whose text is JSON:

```json title="request_purchase error"
{
  "error_code": "POLICY_DENIED",
  "reason_code": "HARD_CAP_EXCEEDED",
  "message": "...",
  "retryable": false,
  "next_action": "...",
  "intent_id": "pi_..."
}
```

Claude Code reports the reason and follows `next_action`. For <ReasonCode code="BUDGET_EXCEEDED" /> it can call `get_spending_status` to see what is left. A denial is final for that purchase.

## Troubleshooting [#troubleshooting]

| Symptom | Cause and fix |
| --- | --- |
| Every tool call fails with `AGENT_CREDENTIAL_INVALID` | The credential is wrong, rotated or revoked (<ReasonCode code="AGENT_CREDENTIAL_INVALID" />). Remove the server with `claude mcp remove abazi`, set the new key and add it again. The tool list still loads with a bad key; only the calls fail. |
| `abazi` is missing from `/mcp`, or shows no tools | The URL must end in `/mcp` and use `--transport http`. Run `claude mcp list` to see the stored URL. With `--scope project`, approve the project server when Claude Code asks. |
| The purchase stays `awaiting_approval` | A person has not decided yet. Keep polling the same `intent_id`; do not start a new purchase. |
| `IDEMPOTENCY_CONFLICT` | The same `idempotency_key` was sent with a different request. Use a new key for a different purchase; reuse a key only to retry the same one. |

## Next steps [#next-steps]

<Cards>
  <Card title="MCP tools" href="/docs/mcp" description="Inputs, results and errors of the six tools." />
  <Card title="Write a mandate" href="/docs/guides/write-a-mandate" description="Set the limits Claude Code buys under." />
  <Card title="Reason codes" href="/docs/api/errors-and-reason-codes" description="Every decision and its next action." />
  <Card title="All harnesses" href="/docs/agents" description="Compare the other ways to connect." />
</Cards>

