Skip to main content
Glama

helius_execute_jupiter_swap

Swap tokens on Solana using Jupiter. Specify input and output token mints, amount, and signer.

Instructions

Execute a token swap using Jupiter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputMintYesThe mint address of the input token
outputMintYesThe mint address of the output token
amountYesThe amount of input tokens to swap
maxDynamicSlippageBpsNoMaximum slippage in basis points (optional)
signerYesThe signer public key

Implementation Reference

  • Handler function that executes a Jupiter swap. Validates the signer public key, constructs params with inputMint/outputMint/amount/maxDynamicSlippageBps, then calls helius.rpc.executeJupiterSwap and returns the result.
    export const executeJupiterSwapHandler = async (input: ExecuteJupiterSwapInput): Promise<ToolResultSchema> => {
      try {
        // Validate the signer is a valid public key format
        const signerPublicKey = validatePublicKey(input.signer);
        if (!(signerPublicKey instanceof PublicKey)) {
          return signerPublicKey;
        }
    
        const params = {
          inputMint: input.inputMint,
          outputMint: input.outputMint,
          amount: input.amount,
          maxDynamicSlippageBps: input.maxDynamicSlippageBps
        };
    
        // The actual implementation expects a Signer object, but our mock likely accepts a string
        // We'll use the string and let the type casting handle it
        const result = await (helius as any as Helius).rpc.executeJupiterSwap(params, input.signer as any);
        return createSuccessResponse(`Jupiter swap executed: ${JSON.stringify(result, null, 2)}`);
      } catch (error) {
        return createErrorResponse(`Error executing Jupiter swap: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Type definition for ExecuteJupiterSwapInput containing inputMint, outputMint, amount, optional maxDynamicSlippageBps, and signer fields.
    export type ExecuteJupiterSwapInput = {
      inputMint: string;
      outputMint: string;
      amount: number;
      maxDynamicSlippageBps?: number;
      signer: string;
    }
  • Tool registration entry defining name 'helius_execute_jupiter_swap', description, and inputSchema with inputMint, outputMint, amount, maxDynamicSlippageBps, signer properties.
    {
      name: 'helius_execute_jupiter_swap',
      description: 'Execute a token swap using Jupiter',
      inputSchema: {
        type: 'object',
        properties: {
          inputMint: { type: 'string', description: 'The mint address of the input token' },
          outputMint: { type: 'string', description: 'The mint address of the output token' },
          amount: { type: 'number', description: 'The amount of input tokens to swap' },
          maxDynamicSlippageBps: { type: 'number', description: 'Maximum slippage in basis points (optional)' },
          signer: { type: 'string', description: 'The signer public key' }
        },
        required: ['inputMint', 'outputMint', 'amount', 'signer']
      }
    }
  • src/tools.ts:549-591 (registration)
    Handler dictionary mapping tool name 'helius_execute_jupiter_swap' to executeJupiterSwapHandler function.
    export const handlers: handlerDictionary = {
      "helius_get_balance": getBalanceHandler,
      "helius_get_block_height": getBlockHeightHandler,
      "helius_get_token_accounts_by_owner": getTokenAccountsByOwnerHandler,
      "helius_get_token_supply": getTokenSupplyHandler,
      "helius_get_token_largest_accounts": getTokenLargestAccountsHandler,
      "helius_get_latest_blockhash": getLatestBlockhashHandler,
      "helius_get_token_account_balance": getTokenAccountBalanceHandler,
      "helius_get_slot": getSlotHandler,
      "helius_get_transaction": getTransactionHandler,
      // New handlers
      "helius_get_account_info": getAccountInfoHandler,
      "helius_get_program_accounts": getProgramAccountsHandler,
      "helius_get_signatures_for_address": getSignaturesForAddressHandler,
      "helius_get_minimum_balance_for_rent_exemption": getMinimumBalanceForRentExemptionHandler,
      "helius_get_multiple_accounts": getMultipleAccountsHandler,
      "helius_get_inflation_reward": getInflationRewardHandler,
      "helius_get_epoch_info": getEpochInfoHandler,
      "helius_get_epoch_schedule": getEpochScheduleHandler,
      "helius_get_leader_schedule": getLeaderScheduleHandler,
      "helius_get_recent_performance_samples": getRecentPerformanceSamplesHandler,
      "helius_get_version": getVersionHandler,
      // DAS Methods
      "helius_get_asset": helius.getAssetHandler,
      "helius_get_rwa_asset": helius.getRwaAssetHandler,
      "helius_get_asset_batch": helius.getAssetBatchHandler,
      "helius_get_asset_proof": helius.getAssetProofHandler,
      "helius_get_assets_by_group": helius.getAssetsByGroupHandler,
      "helius_get_assets_by_owner": helius.getAssetsByOwnerHandler,
      "helius_get_assets_by_creator": helius.getAssetsByCreatorHandler,
      "helius_get_assets_by_authority": helius.getAssetsByAuthorityHandler,
      "helius_search_assets": helius.searchAssetsHandler,
      "helius_get_signatures_for_asset": helius.getSignaturesForAssetHandler,
      "helius_get_nft_editions": helius.getNftEditionsHandler,
      "helius_get_token_accounts": helius.getTokenAccountsHandler,
      // Transaction and Fee Methods
      "helius_get_priority_fee_estimate": helius.getPriorityFeeEstimateHandler,
      "helius_poll_transaction_confirmation": helius.pollTransactionConfirmationHandler,
      "helius_send_jito_bundle": helius.sendJitoBundleHandler,
      "helius_get_bundle_statuses": helius.getBundleStatusesHandler,
      "helius_get_fee_for_message": getFeeForMessageHandler,
      "helius_execute_jupiter_swap": executeJupiterSwapHandler
      // "print_environment": printEnvironmentHandler,
  • Utility function validatePublicKey used by the handler to validate the signer public key before executing the swap.
    export const validatePublicKey = (publicKeyString: string): PublicKey | ToolResultSchema => {
      const { publicKey, error } = createPublicKey(publicKeyString);
      if (error) {
        return createErrorResponse(error);
      }
      return publicKey!;
    }; 
Behavior2/5

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

No annotations exist, so the description must fully disclose behavior. It only says 'execute', omitting critical details like whether the tool signs transactions, confirmation behavior, error handling, or side effects (e.g., token transfers). This is insufficient for a mutation tool.

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

Conciseness3/5

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

The description is a single sentence, which is concise but lacks structure. It does not front-load key details or organize information. While brevity is a virtue, the tool's complexity warrants more sentences.

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?

Given the tool's complexity (5 parameters, no output schema, no annotations), the description is insufficient. It fails to explain return values, slippage usage, signer role, or integration with Jupiter's workflow. Lacks completeness for reliable invocation.

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

Parameters3/5

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

Schema coverage is 100% with descriptions for each parameter, so the baseline is 3. The description adds no additional meaning beyond the schema, e.g., whether 'amount' is in lamports or token decimals. No extra value.

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

Purpose5/5

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

The description clearly states 'Execute a token swap using Jupiter', which identifies the specific action (execute), resource (token swap), and platform (Jupiter). Among siblings, most are read-only queries, making this tool's purpose distinct.

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 on when to use this tool versus alternatives like 'helius_send_jito_bundle'. No mention of prerequisites (e.g., needing a quote) or limitations. The description provides no context for tool selection.

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-helius'

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