Skip to main content
Glama

jupiter_swap_build

Get raw swap instructions to construct custom transactions that combine Jupiter swaps with other operations like flash loans or multi-step trades.

Instructions

Get raw swap instructions for custom transaction construction. Use when composing Jupiter swaps with other instructions (flashloans, multi-step). Metis router only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputMintYesMint address of token to sell
outputMintYesMint address of token to buy
amountYesAmount in smallest unit
takerYesWallet address
slippageBpsNoMax slippage in basis points

Implementation Reference

  • Tool handler for 'jupiter_swap_build'. Calls client.swapBuild() to get raw swap instructions via the Jupiter /swap/v2/build endpoint. Returns the response as formatted JSON.
    register(
      "jupiter_swap_build",
      "Get raw swap instructions for custom transaction construction. Use when composing Jupiter swaps with other instructions (flashloans, multi-step). Metis router only.",
      {
        inputMint: z.string().describe("Mint address of token to sell"),
        outputMint: z.string().describe("Mint address of token to buy"),
        amount: z.string().describe("Amount in smallest unit"),
        taker: z.string().describe("Wallet address"),
        slippageBps: z.number().optional().describe("Max slippage in basis points"),
      },
      async (args) => {
        const result = await client.swapBuild(args);
        return JSON.stringify(result, null, 2);
      },
    );
  • Zod schema defining input parameters for the jupiter_swap_build tool: inputMint, outputMint, amount, taker (all required strings), and optional slippageBps (number).
    {
      inputMint: z.string().describe("Mint address of token to sell"),
      outputMint: z.string().describe("Mint address of token to buy"),
      amount: z.string().describe("Amount in smallest unit"),
      taker: z.string().describe("Wallet address"),
      slippageBps: z.number().optional().describe("Max slippage in basis points"),
  • src/index.ts:40-57 (registration)
    The 'register' function that registers each tool with the MCP server (via McpServer.tool()). It wraps the handler with error handling and content formatting.
    function register(
      name: string,
      description: string,
      shape: Record<string, z.ZodType>,
      handler: (args: any) => Promise<string>,
    ) {
      server.tool(name, description, shape, async (args) => {
        try {
          const text = await handler(args);
          return { content: [{ type: "text" as const, text }] };
        } catch (err: any) {
          return {
            content: [{ type: "text" as const, text: `Error: ${err.message}` }],
            isError: true,
          };
        }
      });
      toolCount++;
  • JupiterClient.swapBuild() — the API client method that sends a GET request to /swap/v2/build with the swap parameters to get raw swap instructions.
    async swapBuild(params: {
      inputMint: string;
      outputMint: string;
      amount: string;
      taker: string;
      slippageBps?: number;
    }) {
      return this.request("/swap/v2/build", { params: params as any });
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool returns raw instructions (non-executing) and limits to Metis router, but does not mention side effects, auth requirements, or error behavior. With no annotation support, more behavioral context is needed for safe invocation.

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?

Two sentences, no redundant information. The first sentence conveys the core purpose concisely; the second provides critical usage context. Well-structured for quick comprehension.

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

Completeness3/5

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

Given 5 parameters, no output schema, and no annotations, the description is adequate but lacks details about return format (raw instructions), prerequisites (e.g., prior quote), and error handling. It provides essential usage guidance but leaves some gaps for a complex tool.

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 description coverage is 100%, so baseline is 3. The description does not add significant meaning beyond the parameter names and their inline descriptions. For example, 'amount' already says 'Amount in smallest unit' in schema; description adds no further detail.

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 the tool's verb ('Get raw swap instructions') and resource ('custom transaction construction'). It distinguishes itself from siblings by highlighting its use case for composing swaps with other instructions, and mentions 'Metis router only'.

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

Usage Guidelines4/5

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

Explicitly states when to use: 'Use when composing Jupiter swaps with other instructions (flashloans, multi-step).' Also provides a specific constraint: 'Metis router only.' However, it does not explicitly state when not to use or name alternatives.

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/ExpertVagabond/jupiter-mcp'

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