Set up Route with your AI agent
One prompt for Claude Code, Cursor or Codex that adds Intents Route cross-chain swaps to your app — MCP server, skill, SDK, a key-safe proxy, quotes and wallet execution.
Open your app’s root in a coding agent and paste this one line:
Read https://intents.fi/docs/agent-setup/route.md and follow it.Or copy the whole prompt below. Route has no test mode, but the agent never signs anything: nothing moves until you approve a swap in your own wallet. This prompt is for letting your users swap and move funds across chains; to get paid, use the Intents Checkout prompt instead. Per-agent install details: Claude Code, Cursor, Codex.
Set up Intents Route in this project
Section titled “Set up Intents Route in this project”You are a coding agent adding Intents Route to this project so its users can swap and move their own funds across tokens and chains. Route quotes every intent protocol in one request, ranks the answers, and turns the chosen quote into an execution plan that the user’s own wallet signs; intents.fi then tracks the order to completion. It never holds funds or keys.
This prompt is only about Route. Do not create invoices and do not read the Intents Checkout pages. (If the
human actually wants to get paid, stop and follow https://intents.fi/docs/agent-setup/checkout.md
instead.)
Follow the steps in order. Stop and ask the human only where a step says ASK.
Rules for the whole session
Section titled “Rules for the whole session”- Never sign or send a transaction, and never ask for a private key or seed phrase. The user’s wallet does every signing step, in the browser, after the user approves it.
- Route has no test mode. Quotes and orders are real with any key. You may request quotes as often as you like; you never execute a swap yourself. The human does the first real swap, with a small amount.
- The secret key lives in
.env.local(check it is in.gitignore) and in server code only. The browser talks to the project’s own proxy, which adds the key. The key is never imported by a client component, printed, logged or committed. - Amounts are integer strings in base units. Do maths in
BigInt, never floats, and format with the asset’sdecimalsonly for display. - Show the user
output.amountMin(the least they will receive) before they sign, not onlyamountExpected. - Do not invent API fields. When unsure, read the docs: the
docs_searchanddocs_get_pageMCP tools, orhttps://intents.fi/docs/route/llms.txt(the Route pages; every page is markdown at its URL plus.md).
Step 1: install the MCP server and the skill
Section titled “Step 1: install the MCP server and the skill”Install the intents.fi MCP server (@intents-fi/mcp, run with npx -y @intents-fi/mcp) with
INTENTS_API_KEY set to the key and INTENTS_TOOLSETS=docs,routing, and the
integrate-intents-route skill from https://github.com/intents-fi/skills. The routing tools are
read-only: compare_quotes, get_status, list_routes, get_route_status. How depends on the
agent you are:
- Claude Code:
claude mcp add intents-fi -e INTENTS_API_KEY=ik_… -e INTENTS_TOOLSETS=docs,routing -- npx -y @intents-fi/mcp, then clonehttps://github.com/intents-fi/skillsto a temporary directory and copy itsintegrate-intents-routefolder into.claude/skills/(as.claude/skills/integrate-intents-route/SKILL.md). - Cursor: add the server to
.cursor/mcp.json; seehttps://intents.fi/docs/agent-setup/cursor.md. - Codex: add the server to
~/.codex/config.toml; seehttps://intents.fi/docs/agent-setup/codex.md.
ASK the human for a secret key (dashboard.intents.fi → Developers → API keys) if one is not
already in the environment. An ik_test_ key is fine: Route quotes are real either way. If the
agent cannot load MCP servers, carry on without them: everything below also works from the docs.
Step 2: install the SDK
Section titled “Step 2: install the SDK”Look at how the project connects wallets (wagmi / viem for EVM, @solana/wallet-adapter for
Solana). Install @intents-fi/sdk and the matching peer: viem for EVM, @solana/web3.js for
Solana, both if the project has both.
npm install @intents-fi/sdk viemIf the project has no wallet connection at all, ASK the human which wallets to support before adding one.
Step 3: the key-safe proxy
Section titled “Step 3: the key-safe proxy”These files assume a Next.js App Router project. For another framework, keep the same piece — a server route that forwards the five Route endpoints and adds the key — and adapt the wiring.
.env.local (append; never commit it):
INTENTS_API_KEY=ik_…app/api/intents/[...path]/route.ts:
const ALLOWED = [/^v0\/quotes$/, /^v0\/orders$/, /^v0\/orders\/[\w-]+(\/submit)?$/, /^v0\/chains$/, /^v0\/assets$/];
async function proxy(req: Request, ctx: { params: Promise<{ path: string[] }> }) { const path = (await ctx.params).path.join("/"); if (!ALLOWED.some((re) => re.test(path))) { return Response.json({ error: { code: "NOT_FOUND", message: "Not proxied" } }, { status: 404 }); } const url = new URL(`https://api.intents.fi/${path}`); url.search = new URL(req.url).search; const res = await fetch(url, { method: req.method, headers: { "content-type": "application/json", authorization: `Bearer ${process.env.INTENTS_API_KEY}` }, ...(req.method !== "GET" && { body: await req.text() }), }); return new Response(res.body, { status: res.status, headers: { "content-type": "application/json" } });}
export const GET = proxy;export const POST = proxy;lib/intents-client.ts, the browser client (it holds no key):
import { createClient } from "@intents-fi/sdk";
export const intents = createClient({ apiKey: "proxied", baseUrl: `${window.location.origin}/api/intents` });Only import it from client components.
Step 4: quotes
Section titled “Step 4: quotes”ASK the human where the swap should live (a new /swap page, or an existing screen) and which
pairs matter most, unless that is already clear.
Build the quote step with the project’s own UI components:
- Inputs: from asset, to asset and amount. Asset IDs are CAIP-19 or the
alias:addressshorthand (arbitrum:0xaf88d065e77c8cc2239327c5edb3a432268e5831is USDC on Arbitrum). List what is routable withGET /v0/chainsandGET /v0/assets?chain=<alias>&q=<search>through the proxy. senderis the connected wallet’s address on the source chain;recipientdefaults to the same user’s address on the destination chain.- Call
intents.quotes.create({ from, to, sender, recipient, executionModes: executionModesFor(wallets) }). Show each quote’sprovider,output.amountMin,fees.totalUsdandetaSeconds, withbestpreselected. - On
NO_ROUTE, show the reasons inerror.details.errorsrather than a bare failure. - Quotes expire (
expiresAt, often under a minute): re-quote when the inputs change or the quote ages out.
Step 5: execution
Section titled “Step 5: execution”When the user confirms, run the swap in their wallet:
import { executionModesFor, swap } from "@intents-fi/sdk";
const order = await swap( intents, { from, to, sender, recipient, pick: (qs) => qs.find((q) => q.id === chosenId) }, wallets, // { evm: { walletClient } } and/or { solana: { publicKey, signAndSendTransaction, connection } } { onStep: (e) => showStep(e), // approve / swap / signature, with txHash onTransferRequired: (t) => showDepositAddress(t), // chains the wallet can't send on onUpdate: (o) => showStatus(o.status), },);Show every state to the user: awaiting_user, submitted, pending_deposit, processing, then
completed (with output.amountActual), refunded, failed (with failReason) or expired.
On QUOTE_DRIFT, show the fresh quote from the error and let the user confirm again.
Step 6: check it works
Section titled “Step 6: check it works”- Use the MCP tool
compare_quotesfor a small real pair (for example 10 USDC from Arbitrum to Base) and check several protocols answer. - Run the dev server and request the same quote through the app’s proxy:
curl -X POST localhost:3000/api/intents/v0/quotes -H 'content-type: application/json' -d '…'. Expect200withquotesandbest. A path outside the five endpoints must answer404. - Build the app and confirm the key is not in the client bundle (
grep -r "ik_" .next/staticfinds nothing). - Open the swap screen, connect a wallet and check the quotes render with
amountMin. Do not execute.
If a step fails, read the error code on https://intents.fi/docs/route/index.md (“Errors you will
meet”) and fix the cause rather than working around it.
Step 7: tell the human
Section titled “Step 7: tell the human”Summarise what you created. Tell them Route has no test mode, so the first real swap is theirs to
make, with a small amount, from their own wallet; and that https://intents.fi/docs/status shows
live success rates per protocol.