> ## 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 for AI agents

> Pegana's Model Context Protocol server gives Claude, Cursor, Cline and Continue native access to live peg state. Five free tools, three paid tools settled in USDC via x402.

[Model Context Protocol](https://modelcontextprotocol.io) (MCP) is the standard
agents use to discover and call tools. Pegana ships an MCP server that exposes peg
state, history, methodology metadata, and a live event subscription — directly to
the model, without needing a wrapper API call.

**Hosted endpoint:** `https://mcp.pegana.xyz` (Streamable HTTP transport)
**Source:** `mcp-ts/` (TypeScript on Bun + Hono)

Point your MCP host at the URL — no install, no clone, no API key. See
[setup](/docs/guides/mcp-setup-claude) for per-host config.

## Why MCP

If your agent already lives in Claude Code, Cursor, Cline, or Continue, MCP is the
shortest path to "the model knows the peg state." No middleware, no toolchain — the
model calls `get_asset_state("USDC")` and gets back JSON.

The model also discovers methodology and asset metadata via `get_methodology` and
`get_assets`, so it can reason about *why* an alert fires before reading any code you
wrote.

## Tools available

<CardGroup cols={2}>
  <Card title="Free tools" icon="circle-check" href="/docs/guides/mcp-free-tools">
    `ping`, `get_assets`, `get_asset_state`, `get_methodology`, `verify_alert`. No payment, no key.
  </Card>

  <Card title="Paid tools (x402)" icon="coins" href="/docs/guides/mcp-paid-tools-x402">
    `ping_paid` ($0.001), `get_asset_history` ($0.001), `subscribe_peg_events` (\$0.0005). Settled in USDC on Solana.
  </Card>
</CardGroup>

## Setup

<Card title="Add Pegana to Claude / Cursor / Cline" icon="rocket" href="/docs/guides/mcp-setup-claude">
  One-time config in your MCP host's settings file.
</Card>

## A typical agent prompt

Once configured:

```text theme={"theme":"github-dark"}
You have a Pegana MCP server. Before recommending any swap to or from a
pegged asset on Solana, call get_asset_state({asset}) and refuse if the
state is not PEGGED (unless the user explicitly accepts the risk).
```

The model handles the rest. It will call `get_asset_state("USDC")` on its own,
inspect the result, and refuse a swap if state is `DRIFT` or worse.

## Tool list

| Tool                   | Free?    | Description                                                                               |
| ---------------------- | -------- | ----------------------------------------------------------------------------------------- |
| `ping`                 | ✓        | Server liveness check                                                                     |
| `get_assets`           | ✓        | List all active assets with latest snapshot                                               |
| `get_asset_state`      | ✓        | Current state, intrinsic, market, spread for one asset                                    |
| `get_methodology`      | ✓        | Formula, sources, FSM thresholds — for the model to reason from                           |
| `verify_alert`         | ✓        | Verify an on-chain alert receipt — proxies `GET /v1/audit/:alert_id`, data already public |
| `ping_paid`            | \$0.001  | x402 wiring smoke test (settles a real micro-payment)                                     |
| `get_asset_history`    | \$0.001  | Discount history beyond 24h, 1m/5m/15m/1h bucket                                          |
| `subscribe_peg_events` | \$0.0005 | Replay state transitions since a timestamp                                                |

## Hosted — no clone needed

The server is hosted at `mcp.pegana.xyz` — no clone needed; see
[pegana.xyz/developers](https://pegana.xyz/developers). Just point your MCP host at
the URL — no install, no API key. The runtime is `mcp-ts/` (TypeScript on Bun + Hono),
configured via env vars (`PEGANA_API_BASE`, `REDIS_URL`, `DATABASE_URL`, plus the CDP
block for paid tools).

## Anti-prompt-injection note

The MCP server returns structured JSON — no markdown, no nested instructions, no
"ignore previous" payloads. We do not flow user-provided strings back into the
response. The `get_methodology` content is static (vendored at build time), so an
attacker compromising `api.pegana.xyz` cannot inject prompts via the methodology
response.

The values we *do* return (`asset`, `state`, decimal numbers, timestamps) are
constrained shapes — your model can treat them as data, not prompts.

## Next

<CardGroup cols={2}>
  <Card title="Free tools detail" icon="circle-check" href="/docs/guides/mcp-free-tools">
    Schemas + example calls for each free tool.
  </Card>

  <Card title="Paid tools + x402" icon="coins" href="/docs/guides/mcp-paid-tools-x402">
    Settlement flow with Coinbase CDP wallet.
  </Card>
</CardGroup>
