Skip to main content
Glama

jupiter_send_swap_transaction

Execute token swap transactions on the Solana blockchain using Jupiter's API. Send pre-built swap transactions with configurable retry and validation options.

Instructions

Send a swap transaction on Jupiter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
swapTransactionNo
serializedTransactionNo
skipPreflightNo
maxRetriesNo

Implementation Reference

  • The core handler function that processes the tool input, constructs the request to Jupiter's /swap API endpoint, sends the POST request, and returns a formatted success or error response.
    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)}`); } };
  • The tool definition including name, description, and JSON input schema for validation.
    { 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:62-62 (registration)
    Registration of the handler function in the handlers dictionary.
    "jupiter_send_swap_transaction": sendSwapTransactionHandler
  • TypeScript interface defining the input shape for the handler, matching the JSON schema.
    export interface SendSwapTransactionInput { swapTransaction: string; serializedTransaction?: string; skipPreflight?: boolean; maxRetries?: number; }
  • src/tools.ts:3-55 (registration)
    The tools array where the tool is registered with its schema (excerpt shows the relevant part). Note: full array starts at line 3 ends 55.
    export const tools = [ { name: "jupiter_get_quote", description: "Get a quote for swapping tokens on Jupiter", inputSchema: { type: "object", properties: { inputMint: { type: "string" }, outputMint: { type: "string" }, amount: { type: "string" }, slippageBps: { type: "number" }, onlyDirectRoutes: { type: "boolean" }, asLegacyTransaction: { type: "boolean" }, maxAccounts: { type: "number" }, swapMode: { type: "string" }, excludeDexes: { type: "array", items: { type: "string" } }, platformFeeBps: { type: "number" } }, required: ["inputMint", "outputMint", "amount"] } }, { name: "jupiter_build_swap_transaction", description: "Build a swap transaction on Jupiter", inputSchema: { type: "object", properties: { quoteResponse: { type: "string" }, userPublicKey: { type: "string" }, prioritizationFeeLamports: { type: "number" }, computeUnitPriceMicroLamports: { type: "number" }, asLegacyTransaction: { type: "boolean" } }, required: ["quoteResponse", "userPublicKey"] } }, { 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" } } } } ];

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