Guides

MCP Server

Connect any AI agent to Project 0 through the hosted MCP server at ai.0.xyz. Live rates, strategies, health, and unsigned transaction builders. Your wallet signs.

Project 0 runs a hosted MCP server at https://ai.0.xyz/mcp. It gives any MCP-capable agent (Claude Code, Cursor, Codex, custom agents) 15 tools for reading the market and building transactions. Every transaction comes back unsigned: the agent's own wallet signs and sends it, and the server never holds keys.

The same capabilities are available as plain HTTP under https://ai.0.xyz/v1 for agents that don't speak MCP. The OpenAPI spec is at ai.0.xyz/v1/openapi.json.

Connect

claude mcp add --transport http project0 https://ai.0.xyz/mcp

Tools

ToolWhat it does
p0_get_banksLending banks across Project 0, Kamino, Drift and Jupiter Lend with live rates, size and limits
p0_get_strategiesRanked loop and rate-arbitrage strategies with max leverage and capacity
p0_get_walletToken holdings and USD values for a wallet
p0_get_positionsAn account's positions, health, and how much it can borrow or withdraw
p0_get_healthQuick health-factor check
p0_get_activityRecent account activity
p0_search_docs / p0_get_docSearch and read these docs
p0_create_accountBuild a create-account transaction
p0_deposit / p0_withdrawBuild a deposit or withdraw
p0_borrow / p0_repayBuild a borrow or repay
p0_loopOpen or increase a leveraged position in one flash-loan transaction
p0_close_positionUnwind a position by repaying debt with collateral in one flash-loan transaction

Read tools return JSON the agent can reason over directly. Amounts on the wire are UI token units (1.5 = 1.5 tokens).

How transactions work

Every builder returns the same envelope:

{
  "account": "…",
  "transactions": [
    { "base64": "…", "type": "CRANK", "label": "Update oracle" },
    { "base64": "…", "type": "DEPOSIT", "label": "Deposit" }
  ],
  "action_tx_index": 1,
  "submit": "sequential",
  "blockhash": { "value": "…", "last_valid_block_height": 123456789 },
  "simulation": {
    "success": true,
    "post_health": { "status": "healthy", "health_factor": 0.61 },
    "warnings": []
  }
}
  1. Sign every transaction with the authority wallet.
  2. Submit according to submit:
    • sequential: send in array order, waiting for each to confirm.
    • bundle: sign all with the returned blockhash and submit them together as one atomic Jito bundle. Sending them one by one will fail or leave a position half-open.
  3. Treat a landed signature with a non-null err as a failed transaction.

Transactions are simulated before they are returned; if the simulation fails, nothing is returned and the error says why. simulation.post_health is the account's health after the action lands. The blockhash expires in about a minute; if it does, call the tool again.

Transactions are unsigned by design. The server cannot move funds, and there is nothing to revoke.

Example: run a strategy

  1. p0_get_strategies and pick one, for example supply.bank = 4ecR…, borrow.bank = 2s37…, max_leverage = 2.44.
  2. p0_loop:
{
  "authority": "<wallet>",
  "create_new_account": true,
  "deposit_bank": "<strategy.supply.bank>",
  "borrow_bank": "<strategy.borrow.bank>",
  "amount": 0.5,
  "leverage": 2
}

amount is principal already in the wallet, in deposit-token units. leverage must be at or below the strategy's max_leverage. create_new_account: true isolates the position in a fresh account, which is what the app does; pass account instead to add to an existing one.

  1. Sign and send per submit.
  2. To unwind, p0_close_position with repay_all: true (or an amount for a partial repay; at most 250,000 USD of debt per call).

Bring your own aggregator keys

Loops and closes route swaps through Jupiter and Titan using the server's keys. To use your own, send them as HTTP headers on the connection. Never put keys in tool arguments.

claude mcp add --transport http project0 https://ai.0.xyz/mcp \
  --header "x-jupiter-api-key: <key>" \
  --header "x-titan-api-key: <key>"

The same headers work on POST /v1/tx/loop and POST /v1/tx/close-position.

Limits and errors

Rate limits per client IP: 120 requests per minute on /mcp, 60 on /v1, 10 on /v1/tx/*, 4 on loop and close-position. A 429 carries Retry-After.

Errors come back as { "error": "<what to change>", "code": "<CODE>", "details": { … } }. Common codes:

CodeMeaning
ACCOUNT_AMBIGUOUSThe wallet owns several accounts; pass account
BORROW_LIMIT_EXCEEDEDOver the max borrow; details.max_borrow is the cap
LEVERAGE_EXCEEDEDOver the pair's max leverage; details.max_leverage is the cap
SWAP_ROUTE_UNAVAILABLE / TX_TOO_LARGENo swap route fits; reduce the amount or pick a more liquid pair
SIMULATION_FAILEDThe transaction would fail on-chain; the cause is in details
RATE_LIMITEDBack off for Retry-After seconds

On this page