Skip to content
Intents Route

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.

Open the raw prompt

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.

  • 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’s decimals only for display.
  • Show the user output.amountMin (the least they will receive) before they sign, not only amountExpected.
  • Do not invent API fields. When unsure, read the docs: the docs_search and docs_get_page MCP tools, or https://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 clone https://github.com/intents-fi/skills to a temporary directory and copy its integrate-intents-route folder into .claude/skills/ (as .claude/skills/integrate-intents-route/SKILL.md).
  • Cursor: add the server to .cursor/mcp.json; see https://intents.fi/docs/agent-setup/cursor.md.
  • Codex: add the server to ~/.codex/config.toml; see https://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.

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.

Terminal window
npm install @intents-fi/sdk viem

If the project has no wallet connection at all, ASK the human which wallets to support before adding one.

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):

Terminal window
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.

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:address shorthand (arbitrum:0xaf88d065e77c8cc2239327c5edb3a432268e5831 is USDC on Arbitrum). List what is routable with GET /v0/chains and GET /v0/assets?chain=<alias>&q=<search> through the proxy.
  • sender is the connected wallet’s address on the source chain; recipient defaults to the same user’s address on the destination chain.
  • Call intents.quotes.create({ from, to, sender, recipient, executionModes: executionModesFor(wallets) }). Show each quote’s provider, output.amountMin, fees.totalUsd and etaSeconds, with best preselected.
  • On NO_ROUTE, show the reasons in error.details.errors rather than a bare failure.
  • Quotes expire (expiresAt, often under a minute): re-quote when the inputs change or the quote ages out.

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.

  1. Use the MCP tool compare_quotes for a small real pair (for example 10 USDC from Arbitrum to Base) and check several protocols answer.
  2. 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 '…'. Expect 200 with quotes and best. A path outside the five endpoints must answer 404.
  3. Build the app and confirm the key is not in the client bundle (grep -r "ik_" .next/static finds nothing).
  4. 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.

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.