jupiter_swap_quote
Get the best swap quote by aggregating prices from multiple Solana DEX routers. Specify tokens, amount, wallet, and slippage to receive an optimized quote.
Instructions
Get a swap quote via Jupiter's managed /order path. Returns the best price across all routers (Metis, RFQ, Dflow, OKX).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputMint | Yes | Mint address of token to sell (SOL: So11111111111111111111111111111111111111112) | |
| outputMint | Yes | Mint address of token to buy (USDC: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v) | |
| amount | Yes | Amount in smallest unit (lamports). For 1 SOL: '1000000000' | |
| taker | Yes | Wallet address executing the swap | |
| slippageBps | No | Max slippage in basis points (default 50 = 0.5%) |
Implementation Reference
- src/tools/swap.ts:6-20 (handler)The handler function for jupiter_swap_quote — calls client.swapOrder(args) with the user's input (inputMint, outputMint, amount, taker, slippageBps) and returns the JSON-stringified result.
register( "jupiter_swap_quote", "Get a swap quote via Jupiter's managed /order path. Returns the best price across all routers (Metis, RFQ, Dflow, OKX).", { inputMint: z.string().describe("Mint address of token to sell (SOL: So11111111111111111111111111111111111111112)"), outputMint: z.string().describe("Mint address of token to buy (USDC: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)"), amount: z.string().describe("Amount in smallest unit (lamports). For 1 SOL: '1000000000'"), taker: z.string().describe("Wallet address executing the swap"), slippageBps: z.number().optional().describe("Max slippage in basis points (default 50 = 0.5%)"), }, async (args) => { const result = await client.swapOrder(args); return JSON.stringify(result, null, 2); }, ); - src/tools/swap.ts:9-15 (schema)Zod schema defining the 5 input parameters: inputMint (string), outputMint (string), amount (string), taker (string), slippageBps (optional number).
{ inputMint: z.string().describe("Mint address of token to sell (SOL: So11111111111111111111111111111111111111112)"), outputMint: z.string().describe("Mint address of token to buy (USDC: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)"), amount: z.string().describe("Amount in smallest unit (lamports). For 1 SOL: '1000000000'"), taker: z.string().describe("Wallet address executing the swap"), slippageBps: z.number().optional().describe("Max slippage in basis points (default 50 = 0.5%)"), }, - src/tools/swap.ts:6-20 (registration)Registration of the tool named 'jupiter_swap_quote' via the register function, which internally calls server.tool() on the MCP server.
register( "jupiter_swap_quote", "Get a swap quote via Jupiter's managed /order path. Returns the best price across all routers (Metis, RFQ, Dflow, OKX).", { inputMint: z.string().describe("Mint address of token to sell (SOL: So11111111111111111111111111111111111111112)"), outputMint: z.string().describe("Mint address of token to buy (USDC: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)"), amount: z.string().describe("Amount in smallest unit (lamports). For 1 SOL: '1000000000'"), taker: z.string().describe("Wallet address executing the swap"), slippageBps: z.number().optional().describe("Max slippage in basis points (default 50 = 0.5%)"), }, async (args) => { const result = await client.swapOrder(args); return JSON.stringify(result, null, 2); }, ); - src/index.ts:40-58 (registration)The generic register() helper that maps to McpServer.tool(), used to register the jupiter_swap_quote tool.
function register( name: string, description: string, shape: Record<string, z.ZodType>, handler: (args: any) => Promise<string>, ) { server.tool(name, description, shape, async (args) => { try { const text = await handler(args); return { content: [{ type: "text" as const, text }] }; } catch (err: any) { return { content: [{ type: "text" as const, text: `Error: ${err.message}` }], isError: true, }; } }); toolCount++; } - src/client.ts:60-71 (helper)The underlying JupiterClient method swapOrder() that makes the actual GET request to /swap/v2/order on the Jupiter API.
/** Get a quote + assembled transaction via managed /order path */ async swapOrder(params: { inputMint: string; outputMint: string; amount: string; taker: string; slippageBps?: number; referralAccount?: string; referralFee?: number; }) { return this.request("/swap/v2/order", { params: params as any }); }