Skip to main content
Glama

jupiter_send_swap_transaction

Execute Solana token swaps using Jupiter's API by sending prebuilt swap transactions. Supports optional retries and preflight check skipping for optimized blockchain interactions.

Instructions

Send a swap transaction on Jupiter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxRetriesNo
serializedTransactionNo
skipPreflightNo
swapTransactionNo

Implementation Reference

  • The main handler function that implements the logic for sending a swap transaction to the Jupiter API.
    export const sendSwapTransactionHandler = async (input: SendSwapTransactionInput): Promise<ToolResultSchema> => { try { // Build the request body const requestBody: any = {}; if (input.swapTransaction) { try { requestBody.swapTransaction = JSON.parse(input.swapTransaction); } catch (error) { return createErrorResponse(`Invalid swap transaction: ${error instanceof Error ? error.message : String(error)}`); } } if (input.serializedTransaction) { requestBody.serializedTransaction = input.serializedTransaction; } if (!requestBody.swapTransaction && !requestBody.serializedTransaction) { return createErrorResponse("Either swapTransaction or serializedTransaction must be provided"); } if (input.skipPreflight !== undefined) { requestBody.options = requestBody.options || {}; requestBody.options.skipPreflight = input.skipPreflight; } if (input.maxRetries !== undefined) { requestBody.options = requestBody.options || {}; requestBody.options.maxRetries = input.maxRetries; } // Make the API request const response = await fetch(`${JUPITER_API_BASE_URL}/swap`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(requestBody) }); if (!response.ok) { const errorText = await response.text(); return createErrorResponse(`Error sending swap transaction: ${response.status} ${response.statusText} - ${errorText}`); } const swapResult = await response.json(); return createSuccessResponse(`Swap result: ${JSON.stringify(swapResult, null, 2)}`); } catch (error) { return createErrorResponse(`Error sending swap transaction: ${error instanceof Error ? error.message : String(error)}`); } };
  • TypeScript interface defining the input parameters for the sendSwapTransactionHandler.
    export interface SendSwapTransactionInput { swapTransaction: string; serializedTransaction?: string; skipPreflight?: boolean; maxRetries?: number; }
  • src/tools.ts:42-54 (registration)
    Tool registration in the tools array, including name, description, and input schema for MCP.
    { name: "jupiter_send_swap_transaction", description: "Send a swap transaction on Jupiter", inputSchema: { type: "object", properties: { swapTransaction: { type: "string" }, serializedTransaction: { type: "string" }, skipPreflight: { type: "boolean" }, maxRetries: { type: "number" } } } }
  • src/tools.ts:59-63 (registration)
    Mapping of tool name to its handler function in the handlers dictionary.
    export const handlers: handlerDictionary = { "jupiter_get_quote": getQuoteHandler, "jupiter_build_swap_transaction": buildSwapTransactionHandler, "jupiter_send_swap_transaction": sendSwapTransactionHandler };

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dcSpark/mcp-server-jupiter'

If you have feedback or need assistance with the MCP directory API, please join our Discord server