mcpField
R
RAVN

RAVN

VerifiedFeaturedRemote
ravn.exchangeFinance0Updated 2w ago

About RAVN

RAVN provides examples for a cross-chain swap API spanning EVM chains, native Bitcoin, and Solana, for developers and agents integrating swaps. The examples cover quoting, execution, status tracking, and connecting to the hosted MCP server.

Key features

  1. 01EVM, Bitcoin, and Solana coverage
  2. 02Parallel venue quote comparison
  3. 03Native Bitcoin swaps
  4. 04TypeScript SDK examples
  5. 05Execution and status-tracking flow

Use cases

  1. 01Swap USDC on Base for native BTC
  2. 02Build a Claude tool-calling swap flow
  3. 03Check live venues and run a health test
  4. 04Call the API with per-call x402 payments

MCP support

A hosted MCP server is available, with README instructions for connecting Claude or Cursor. Its endpoint is `https://app.ravn.exchange/api/mcp`.

Configuration

Remote servers need no local install. Pick your client, then copy the config or install in one click.

Endpointhttps://app.ravn.exchange/api/mcp
Copy install command
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

Run commands in a terminal; paste JSON into the client’s MCP config and restart. Servers that need sign-in will prompt on first connect.

Tools

10
ParameterTypeRequiredDescription
inputChainIdintegerYesNumeric chain id, e.g. 1=Ethereum, 8453=Base, -1=Bitcoin, -2=Solana — see ravn_chains for the full list, or ravn_health for live venue status
outputChainIdintegerYesNumeric chain id, e.g. 1=Ethereum, 8453=Base, -1=Bitcoin, -2=Solana — see ravn_chains for the full list, or ravn_health for live venue status
inputTokenstringYesToken contract address, or 0xEeeeeEeeeEeEeeEeEeEeeeEEeeeeEeeeeeeeEEeE for the chain's native coin
outputTokenstringYesToken contract address, or 0xEeeeeEeeeEeEeeEeEeEeeeEEeeeeEeeeeeeeEEeE for the chain's native coin
inputAmountstringYesPositive integer string, in the input token's smallest unit (no decimals)
userAddressstringYesAddress the input asset will be sent from
destinationAddressstringNoWhere output should land, if different from userAddress. Required here, at quote time, to get an executable quote from Relay (Bitcoin as the source), THORChain (Bitcoin either direction), Across (a Solana-touching route), or Eco (a cross-ecosystem route) — omit it there and you get back a priced-but-unexecutable preview instead (see ravn_quote's executable), not an error. A malformed address, one from the wrong ecosystem, or a known non-wallet address (a RAVN-listed token's mint/contract, this swap's own tokens, the native-coin sentinel, burn addresses, Solana core programs, and via an on-chain lookup a Solana token account or program — the token-account error names the owning wallet, which is the address to use) IS an error here — funds sent there are unrecoverable. Omit the field rather than passing an empty string; an empty string is treated as omitted
refundAddressstringNoWhere to refund the input asset if the swap fails. Required here, at quote time, for a Bitcoin-source Relay or THORChain quote — neither has an execute-time re-bind, so omitting it returns a priced-but-unexecutable preview and supplying it later on ravn_execute has no effect. Other BTC-source venues (Garden, Chainflip, Rift) support binding this at execute time instead. Validated against the INPUT chain (refunds are paid back on the origin), with the same non-wallet-address check as destinationAddress
slippageBpsintegerNoMax acceptable slippage in basis points
rankingModeenumNobest_output (default) picks the highest net output; fastest picks the quickest-settling quote within slippageBpsbest_output | fastest
excludeVenuesarrayNoDrop specific venues from this race, e.g. a risk objection to one of them or ravn_health showing it degraded. Naming a venue that was never eligible for this pair is a no-op, not an error
confidentialbooleanNoSettle privately via NEAR Intents' Confidential Intents so the deposit and payout can't be linked on-chain. Through this MCP server only NEAR quotes it (NO_LIQUIDITY if it can't, never a public fallback): RAVN's second private venue, Houdini Swap, needs the end user's IP, user-agent and country for its compliance rules, which an MCP call doesn't carry — use POST /api/v1/quote for it. ~0.3 bps extra on EVM-to-EVM, ~5-8 bps extra when Bitcoin or Solana is a leg, and it can settle slower than a public swap (Bitcoin-source: 13 min public vs 43 min confidential) — read estimatedTimeSeconds before executing
apiKeystringNoYour RAVN API key, if you have one — raises your rate limit

Details

From the project README

RAVN examples

smithery badge

Working code for the RAVN cross-chain swap API — including native Bitcoin, not wrapped BTC.

One integration covers EVM chains, native Bitcoin and Solana. Every quote races every live execution venue in parallel and the best net output wins. RAVN takes 0 bps on every route. Non-custodial: RAVN never holds your funds and writes no smart contracts of its own.

No signup required to start. Every example below runs anonymously.

git clone https://github.com/ravndex/ravn-examples
cd ravn-examples && npm install
npm run health

The examples

What it shows
src/health.ts10-second smoke test — which venues are racing right now. Start here.
src/btc-out.tsUSDC on Base → native BTC, end to end on the SDK's executeAndTrack, fee and status reporting included. The one most swap APIs can't do. Dry-runs without a wallet.
src/agent-swap.tsClaude tool-calling loop: the model picks the swap, your code keeps the keys.
src/x402-client.tsPay-per-call over x402 — no key, no account.
src/ravn.tsThe shared client: the official @ravnexchange/sdk (zero dependencies, typed) plus amount helpers.
MCP.mdPoint Claude or Cursor at the hosted MCP server. Three lines of config.

The contract

Four calls, always the same order.

POST /quote   → best route + an opaque quoteToken
POST /execute → an execution payload tagged by executionType, with its own quoteToken
                (+ submit-signature, when the type is SIGNATURE)
POST /status  → pending → processing → success (or refunded / failed)

Poll /status with the quoteToken execute returned, its statusRef (else your swap's tx hash), and as txHash the hash of the fee payment you sent beside the swap, or on a two-step route (a statusRef came with a TRANSACTION) your swap's own tx hash, until the status is final. Use POST: a quoteToken can run to tens of kilobytes, and a large one in a GET query string fails.

Everything branches on one field:

switch (execution.executionType) {
  case "TRANSACTION": // sign and broadcast it yourself
  case "SIGNATURE":   // sign typed data; RAVN submits it, no gas
  case "DEPOSIT":     // send the input asset to an address
}
The one thing that trips people up

An ERC-20 swap is really two transactions. Before any contract can move your tokens you must sign a separate on-chain permission — an approve(). TRANSACTION and SIGNATURE payloads carry that ready to send, as approval, whenever it's needed.

if (execution.approval) {
  const { to, data, value } = execution.approval;            // value is a decimal string
  const hash = await wallet.sendTransaction({ to, data, value: BigInt(value) });
  await client.waitForTransactionReceipt({ hash });   // MINED, not just broadcast
}
// …now send the swap

Broadcasting the swap before the allowance is mined reverts on transferFrom and the user eats the gas. On gasless venues (CoW, Bebop) it's quieter and worse: the order is accepted and simply never fills, with no error. Native-coin sells and DEPOSIT routes never carry approval.

RAVN reads your user's allowance on-chain at /execute and leaves approval out when it already covers the amount. When that read fails, approval is included anyway, so check the allowance for approval.spender yourself and skip it when it covers approval.amount (btc-out.ts does, through executeAndTrack's hasAllowance). RAVN's read sees the latest block only, so run one swap per token and spender at a time. An approval.reset (Ethereum USDT holding a partial allowance) is an approve(spender, 0) to send and mine first; executeAndTrack does.

0x Gasless can also return approvalData: a second typed-data signature that approves the token gaslessly, sent to /submit-signature as approvalSignature. executeAndTrack signs it for you.

Collecting your fee

If your key sets a fee, a swap only pays you when you do two things:

  1. Pay execution.fee exactly as returned, when there is one (Rift, private swaps, Eco Routes, Layerswap, Mayan routes paying no referrer). EVM: send fee.transaction once the swap has succeeded, or batch an ERC-20 fee with it. Bitcoin: the fee is a second output of the deposit's own transaction. Solana: the transfer goes inside the deposit's own transaction.
  2. Report the swap to /status until it's final, with that fee payment's hash (on a two-step route, your swap's own hash) as txHash on every poll. On same-chain venues RAVN only learns a swap happened from your poll: never reported, never paid.

On a TRANSACTION, executeAndTrack pays the fee and hands you the hash to poll with (statusTxHash); from SDK 0.2.0 its own polling also runs through expired and not_found and retries a failed status call. A DEPOSIT it leaves to you: btc-out.ts sends the deposit and the fee, then polls them all through one loop. The full checklist: https://docs.ravn.exchange/collecting-your-fee

unlimitedRecommended: true (CoW) means the venue would rather you approve once for a large amount than pay approval gas on every swap. data still encodes the exact amount; raising it is your call.

Amounts

Always strings, always the token's smallest unit — wei, lamports, satoshis. Never floats. toBaseUnits() / fromBaseUnits() in src/ravn.ts convert safely.

Cross-ecosystem swaps

Selling on EVM and receiving BTC or SOL needs a destinationAddress — the payout chain has no idea what your EVM address is.

Rate limits

No key30 req/min per IP, plus 120 /status polls/min
Free key, instant, no review120 req/min, plus 480 /status polls/min

Status polls have a budget of their own (4× your limit). Every rate-limited response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (epoch seconds), and a 429 adds Retry-After. Pass your key as x-api-key. CORS is enabled on every endpoint, so browser-side dapps and wallet widgets can call the API directly with no server-side proxy.

Errors

Branch on the stable code, never the message.

INVALID_REQUEST (an unsupported chain is one of these) · UNSUPPORTED_TOKEN · NO_LIQUIDITY · QUOTE_EXPIRED · QUOTE_INVALID · QUOTE_NOT_EXECUTABLE · BUILD_FAILED · ORDER_REJECTED · VENUE_RATE_LIMITED · RATE_LIMITED · UNAUTHORIZED · UNAVAILABLE · NOT_FOUND · NOT_CONFIGURED · INTERNAL. The SDK adds NETWORK_ERROR when no response came back at all. Full table: https://docs.ravn.exchange/errors

Every response carries x-request-id. Quote it if you report a bad quote — it's how we find it.

Links

MIT licensed. Issues and PRs welcome.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.