AI Agents & MCP
Read the Rubin AI agent docs starting at https://docs.rubin.trade/agents/overview (with the Connect, OAuth & Trading Keys and Permissions pages) and connect my agent to the Rubin MCP server on testnet, https://mcp.testnet.rubin.trade/mcp. Use OAuth if the client supports it, otherwise a Bearer credential. If you are building the client yourself, implement the OAuth 2.1 flow described there (discovery, dynamic client registration, PKCE). Then call whoami and list_markets to confirm the session.
Rubin runs an official MCP (Model Context Protocol) server, so an AI agent can read markets and account data and trade without hand-rolling REST calls. The server signs orders with a scoped on-chain trading key, confirms fills and applies safety limits.
| Network | MCP endpoint (Streamable HTTP) | Web app |
|---|---|---|
| mainnet | https://mcp.mainnet.rubin.trade/mcp | https://rubin.trade |
| testnet | https://mcp.testnet.rubin.trade/mcp | https://testnet.rubin.trade |
The network is pinned per server — it is not part of the credential. Start on testnet.
How access works
One session is bound to one Rubin account and acts through a trading key registered on that account on-chain. The key can place and cancel orders but cannot send funds out of the account — see Permissions.
There are two ways to give an agent access:
| Mode | For | The trading key |
|---|---|---|
| OAuth (recommended) | claude.ai, Claude Desktop, ChatGPT, Claude Code, any MCP client with OAuth | Generated by the MCP server; your wallet only approves its public address. The private key never crosses the network — see OAuth & Trading Keys |
| Bearer credential | Headless agents, the Anthropic API, clients without OAuth | Issued in the web app; you hold it and pass it in the Authorization header |
Without any credential a session can list the tools but every call returns an AUTH error. A credential without a trading key gives a read-only session: market data and account reads only.
Tools
| Group | Tools |
|---|---|
| Session | whoami (both address forms, scope, limits), get_block_height |
| Market data | list_markets, get_market, get_orderbook, get_candles, get_candles_multi, get_news |
| Account | get_balance, get_equity, get_positions, get_open_orders, get_portfolio, get_position_risk, get_fills, get_pnl |
| Orders | place_limit_order, place_market_order, open_position (with SL/TP), close_position, close_all_positions, place_stop_loss, place_take_profit, cancel_order, cancel_all_orders, batch_cancel |
| Funds | get_funding_status, deposit_to_subaccount, top_up_gas — between the account's own wallet and subaccount only |
| Profile | get_leaderboard, get_my_rank, get_fee_tier, get_referral_program |
The server also ships ready-made prompts: check_portfolio, scan_markets, protect_positions, enter_trade, flatten_all, assess_situation, my_rank, my_fees, referral_program, fund_account, my_account, latest_news.
Have the agent call whoami first: it returns the account in both address forms (0x… and rit1…), whether the session can trade, and the limits that apply.
Agent skill
A ready-made skill teaches agents the Rubin workflow — connecting, the order flow and the safety rules:
npx skills add rubin-trade/skillsSource: https://github.com/rubin-trade/skills
Testnet funds
The testnet faucet is in the web app's deposit flow, or over REST:
curl -X POST https://faucet.testnet.rubin.trade/faucet/tokens \
-H "Content-Type: application/json" \
-d '{"address": "rit1… or 0x…"}'Pages
- Connect — step-by-step setup for each client
- OAuth & Trading Keys — the authorization flow and how the key is issued without leaving the server
- Permissions — what a trading key can do, limits and how to revoke it