> ## Documentation Index
> Fetch the complete documentation index at: https://pegana.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP — paid tools (x402)

> Three MCP tools settle on-chain in USDC via x402: ping_paid ($0.001/call), get_asset_history ($0.001/call) and subscribe_peg_events ($0.0005/call).

x402 is an HTTP-native payment protocol — the server responds `402 Payment Required`,
the client signs a payment, replays the request, and the server verifies and
settles. For Pegana on Solana, settlement uses USDC via Coinbase Developer Platform
(CDP).

No API key. No subscription. No prepay. Each call is its own payment.

## The paid tools

| Tool                   | Price (USDC) | Returns                                                                  |
| ---------------------- | ------------ | ------------------------------------------------------------------------ |
| `ping_paid`            | \$0.001      | x402 wiring smoke test — settles a real micro-payment and returns a pong |
| `get_asset_history`    | \$0.001      | Discount points beyond 24h, 1m / 5m / 15m / 1h bucket                    |
| `subscribe_peg_events` | \$0.0005     | State transitions since a timestamp                                      |

## get\_asset\_history

```json theme={"theme":"github-dark"}
// → get_asset_history({ symbol: "USDC", bucket: "5m", limit: 288 })
[
  { "ts": "2026-05-20T00:00:00Z", "discount": -0.0001, "state": "PEGGED" },
  { "ts": "2026-05-20T00:05:00Z", "discount": -0.0002, "state": "PEGGED" },
  ...
]
```

* `symbol` — case-sensitive asset symbol (run `get_assets` to enumerate)
* `bucket` — one of 1m / 5m / 15m / 1h (default 1m); there is no raw bucket
* `limit` — rows, most-recent first, default 1000, hard-capped at 50,000
* lookback window is 30 days; rows older than 30 days are never returned

## subscribe\_peg\_events

```json theme={"theme":"github-dark"}
// → subscribe_peg_events({ symbols: ["jitoSOL"], since_ts: 0, threshold_bps: 25 })
[
  {
    "id": "9c8e7f3a-...",
    "asset": "jitoSOL",
    "from_state": "PEGGED",
    "to_state": "DRIFT",
    "discount": -0.0034,
    "ts": 1748186400,
    "evidence_url": "https://pegana.xyz/audit/9c8e7f3a-..."
  },
  ...
]
```

Result rows: `{ id, asset, from_state, to_state, discount, ts, evidence_url }` where
`ts` is unix seconds. `symbols` is a 1–20 element array; `since_ts` is a unix-seconds
cursor (pass `next_cursor` on the next call); optional `threshold_bps` filters by
`|discount|`.

Returns every state transition for the assets since the cursor. For continuous
streaming, prefer the [WebSocket](/docs/guides/websocket) — `subscribe_peg_events` is a
catch-up call for agents that just woke up.

## Settlement flow

```
┌────────────────┐         ┌─────────────────┐         ┌────────────────────┐
│  Agent (MCP    │  call   │  Pegana MCP     │ 402 +   │  x402 Facilitator  │
│   client)      ├────────▶│   server        ├────────▶│  (Coinbase CDP)    │
└────────────────┘         └─────────────────┘         └────────────────────┘
       │                          │                            │
       │   sign USDC transfer     │                            │
       │◀─────────────────────────┤                            │
       │   replay w/ X-Payment    │                            │
       ├─────────────────────────▶│                            │
       │                          │   verify + settle on-chain │
       │                          ├───────────────────────────▶│
       │                          │◀───────────────────────────┤
       │   result JSON            │                            │
       │◀─────────────────────────┤                            │
```

1. Agent calls `get_asset_history(...)` via the MCP client.
2. MCP server responds with HTTP 402 + the payment requirements (recipient, asset
   USDC, amount, chain solana-mainnet, nonce, deadline).
3. The MCP client (the `mcp-remote` bridge or your own) signs a USDC transfer
   via the configured wallet (CDP, or any Solana wallet your client supports).
4. Client replays the request with `X-Payment: <signed payload>` header.
5. Pegana verifies the payment via the x402 facilitator. On success: settles
   on-chain and returns the result. On failure: returns 402 again or 4xx.

The whole round-trip is typically 1.5–3 seconds (signature is fast; on-chain
settlement is the dominant cost). You don't see the on-chain leg as a separate step
from the agent — the bridge handles it.

## Configure your wallet

Point your MCP host at the hosted server and pass CDP credentials to the
`mcp-remote` bridge so it can sign payments locally:

```json claude_desktop_config.json theme={"theme":"github-dark"}
{
  "mcpServers": {
    "pegana": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.pegana.xyz"],
      "env": {
        "X402_WALLET_PROVIDER": "cdp",
        "CDP_API_KEY_ID": "<your CDP API key ID>",
        "CDP_API_KEY_SECRET": "<your CDP API key secret>"
      }
    }
  }
}
```

The server returns HTTP 402 with payment requirements; the bridge signs a USDC
transfer via your CDP wallet and replays the request. Settlement is on Solana
mainnet through Coinbase's x402 facilitator.

Other wallet providers (Phantom, Backpack, hot wallet via private key) are tracked
in the `mcp-ts` README. The default is CDP because it gives the cleanest agent UX —
no browser popup, no wallet extension, just a server-side signing key.

## What if I just want to read history without paying?

The REST endpoint `GET /v1/assets/{symbol}/history` is free for the last 24h.
`get_asset_history` is paid because it returns up to a 30-day lookback at fine bucket
grain (down to 1m), which is more expensive to serve.

If you need >24h of history one-off, the free REST endpoint covers it in 24h
windows. The paid MCP tool is for agents that need it on-demand inside a reasoning
flow.

## Pricing details

* `ping_paid`: **\$0.001 per call** — an x402 wiring smoke test that settles a real micro-payment
* `get_asset_history`: **\$0.001 per call**, regardless of date range or limit
* `subscribe_peg_events`: **\$0.0005 per call**, regardless of result size

Prices are set in `mcp-ts/src/tools/*.ts` and revised periodically as we observe
usage patterns. Major changes will be announced in the [changelog](/docs/changelog).

## On-chain receipts

Every settled payment is an on-chain transaction. The CDP wallet's transaction
history (or any Solana explorer pointed at the facilitator's recipient address) lets
you audit calls.

The x402 settlement path runs on Solana **mainnet** (ADR-0018). The earliest
settlements were self-issued dogfood transactions — roughly 3 early settlements
around 2026-05-27, plus 1 confirmed on 2026-05-31 — verifying the end-to-end
sign → replay → settle flow against the live CDP facilitator before public use.

## Next

<Card title="Setup in Claude Desktop / Cursor" icon="rocket" href="/docs/guides/mcp-setup-claude">
  Step-by-step config for the major MCP hosts.
</Card>
