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/mcpTools
| Tool | What it does |
|---|---|
p0_get_banks | Lending banks across Project 0, Kamino, Drift and Jupiter Lend with live rates, size and limits |
p0_get_strategies | Ranked loop and rate-arbitrage strategies with max leverage and capacity |
p0_get_wallet | Token holdings and USD values for a wallet |
p0_get_positions | An account's positions, health, and how much it can borrow or withdraw |
p0_get_health | Quick health-factor check |
p0_get_activity | Recent account activity |
p0_search_docs / p0_get_doc | Search and read these docs |
p0_create_account | Build a create-account transaction |
p0_deposit / p0_withdraw | Build a deposit or withdraw |
p0_borrow / p0_repay | Build a borrow or repay |
p0_loop | Open or increase a leveraged position in one flash-loan transaction |
p0_close_position | Unwind 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": []
}
}- Sign every transaction with the
authoritywallet. - 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.
- Treat a landed signature with a non-null
erras 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
p0_get_strategiesand pick one, for examplesupply.bank = 4ecR…,borrow.bank = 2s37…,max_leverage = 2.44.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.
- Sign and send per
submit. - To unwind,
p0_close_positionwithrepay_all: true(or anamountfor 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:
| Code | Meaning |
|---|---|
ACCOUNT_AMBIGUOUS | The wallet owns several accounts; pass account |
BORROW_LIMIT_EXCEEDED | Over the max borrow; details.max_borrow is the cap |
LEVERAGE_EXCEEDED | Over the pair's max leverage; details.max_leverage is the cap |
SWAP_ROUTE_UNAVAILABLE / TX_TOO_LARGE | No swap route fits; reduce the amount or pick a more liquid pair |
SIMULATION_FAILED | The transaction would fail on-chain; the cause is in details |
RATE_LIMITED | Back off for Retry-After seconds |
Related
- Agent Skill: a skill file that teaches coding agents Project 0 workflows.
- Looping and Strategies: what a loop is and how strategies are ranked.
- TypeScript SDK: build transactions in your own code.