Skip to main content
Glama

jupiter_get_quote

Get token swap quotes on Solana through Jupiter's API to compare rates and build transactions before executing trades.

Instructions

Get a quote for swapping tokens on Jupiter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputMintYes
outputMintYes
amountYes
slippageBpsNo
onlyDirectRoutesNo
asLegacyTransactionNo
maxAccountsNo
swapModeNo
excludeDexesNo
platformFeeBpsNo

Implementation Reference

  • Main handler function for jupiter_get_quote tool. Validates input mints, builds URLSearchParams for Jupiter quote API, fetches the quote, and returns formatted success or error response.
    export const getQuoteHandler = async (input: GetQuoteInput): Promise<ToolResultSchema> => {
      try {
        // Validate input and output mints
        const inputMintResult = validatePublicKey(input.inputMint);
        if (!(inputMintResult instanceof PublicKey)) {
          return inputMintResult;
        }
        
        const outputMintResult = validatePublicKey(input.outputMint);
        if (!(outputMintResult instanceof PublicKey)) {
          return outputMintResult;
        }
        
        // Build query parameters
        const params = new URLSearchParams();
        params.append("inputMint", input.inputMint);
        params.append("outputMint", input.outputMint);
        params.append("amount", input.amount);
        
        if (input.slippageBps !== undefined) {
          params.append("slippageBps", input.slippageBps.toString());
        }
        
        if (input.onlyDirectRoutes !== undefined) {
          params.append("onlyDirectRoutes", input.onlyDirectRoutes.toString());
        }
        
        if (input.asLegacyTransaction !== undefined) {
          params.append("asLegacyTransaction", input.asLegacyTransaction.toString());
        }
        
        if (input.maxAccounts !== undefined) {
          params.append("maxAccounts", input.maxAccounts.toString());
        }
        
        if (input.swapMode !== undefined) {
          params.append("swapMode", input.swapMode);
        }
        
        if (input.excludeDexes !== undefined && input.excludeDexes.length > 0) {
          params.append("excludeDexes", input.excludeDexes.join(","));
        }
        
        if (input.platformFeeBps !== undefined) {
          params.append("platformFeeBps", input.platformFeeBps.toString());
        }
        
        // Make the API request
        const response = await fetch(`${JUPITER_API_BASE_URL}/quote?${params.toString()}`);
        
        if (!response.ok) {
          const errorText = await response.text();
          return createErrorResponse(`Error getting quote: ${response.status} ${response.statusText} - ${errorText}`);
        }
        
        const quoteData = await response.json();
        return createSuccessResponse(`Quote: ${JSON.stringify(quoteData, null, 2)}`);
      } catch (error) {
        return createErrorResponse(`Error getting quote: ${error instanceof Error ? error.message : String(error)}`);
      }
    };
  • JSON input schema definition for the jupiter_get_quote tool, including properties and required fields.
    {
      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"]
      }
    },
  • src/tools.ts:57-63 (registration)
    Registration of the getQuoteHandler function under the key 'jupiter_get_quote' in the handlers dictionary.
    type handlerDictionary = Record<typeof tools[number]["name"], (input: any) => any>;
    
    export const handlers: handlerDictionary = {
      "jupiter_get_quote": getQuoteHandler,
      "jupiter_build_swap_transaction": buildSwapTransactionHandler,
      "jupiter_send_swap_transaction": sendSwapTransactionHandler
    };
  • TypeScript interface defining the input type GetQuoteInput for the handler, matching the JSON schema.
    export interface GetQuoteInput {
      inputMint: string;
      outputMint: string;
      amount: string;
      slippageBps?: number;
      onlyDirectRoutes?: boolean;
      asLegacyTransaction?: boolean;
      maxAccounts?: number;
      swapMode?: string;
      excludeDexes?: string[];
      platformFeeBps?: number;
    }
  • Helper function validatePublicKey used in the handler to validate input and output mint public keys, returning error response if invalid.
    export const validatePublicKey = (publicKeyString: string): PublicKey | ToolResultSchema => {
      const { publicKey, error } = createPublicKey(publicKeyString);
      if (error) {
        return createErrorResponse(error);
      }
      return publicKey!;
    };
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but fails to do so. It doesn't indicate whether this is a read-only operation, if it has side effects, rate limits, authentication needs, or what the output entails, making it inadequate for a tool with 10 parameters and no output schema.

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 a single, clear sentence with no wasted words, making it highly concise and front-loaded. It efficiently communicates the core purpose without unnecessary elaboration.

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

Completeness1/5

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

Given the complexity (10 parameters, no annotations, no output schema), the description is severely incomplete. It lacks essential details about behavior, parameter meanings, and output expectations, making it insufficient for an agent to use the tool effectively in a multi-step swap process with siblings.

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

Parameters1/5

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

Schema description coverage is 0%, meaning none of the 10 parameters are documented in the schema. The description adds no semantic information about any parameters, such as explaining what 'inputMint', 'slippageBps', or other fields mean, failing to compensate for the lack of schema documentation.

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

Purpose4/5

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

The description clearly states the verb 'Get' and the resource 'a quote for swapping tokens on Jupiter', which specifies the action and domain. However, it doesn't explicitly differentiate from its sibling tools (jupiter_build_swap_transaction and jupiter_send_swap_transaction), which likely handle subsequent steps in the swap process, so it falls short of a perfect score.

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?

The description provides no guidance on when to use this tool versus its siblings. It doesn't mention prerequisites, alternatives, or contextual cues, leaving the agent to infer usage based on tool names alone, which is insufficient for effective 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-jupiter'

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