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" }
          }
        }
      }
    ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. 'Send a swap transaction' implies a write/mutation operation that likely requires authentication and affects blockchain state, but the description doesn't mention permission requirements, transaction finality, error handling, or what happens on success/failure. It provides minimal behavioral context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single 5-word sentence that directly states the tool's purpose. There's no wasted language or unnecessary elaboration, making it efficiently front-loaded with the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a transaction-sending tool with 4 parameters, 0% schema coverage, no annotations, and no output schema, the description is severely incomplete. It doesn't explain what the tool returns, how parameters interact (e.g., relationship between swapTransaction and serializedTransaction), error conditions, or the broader swap workflow context with sibling tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for all 4 parameters, the description provides no information about what 'swapTransaction', 'serializedTransaction', 'skipPreflight', or 'maxRetries' mean or how they should be used. The description doesn't compensate for the complete lack of parameter documentation in the schema, leaving all parameters semantically undefined.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Send a swap transaction on Jupiter' clearly states the action (send) and resource (swap transaction) with the platform context (Jupiter). However, it doesn't differentiate from sibling tools like 'jupiter_build_swap_transaction' or 'jupiter_get_quote' - it's unclear if this tool executes a pre-built transaction or handles the entire swap flow.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus the siblings. The description doesn't indicate if this should be used after building a transaction with 'jupiter_build_swap_transaction' or as an alternative to it, nor does it mention any prerequisites or contextual constraints for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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