Skip to main content
Glama
Pavilion-devs

Saros MCP Server

swap_quote

Calculate token exchange details including price impact, fees, and minimum output amount with slippage for informed trading decisions.

Instructions

Get swap quote for token exchange including price impact, fees, and minimum output amount with slippage.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
poolAddressYesPool address for the swap
fromMintYesSource token mint address
toMintYesDestination token mint address
amountYesAmount to swap (in token decimals)
slippageNoSlippage tolerance (0-100, default 0.5)

Implementation Reference

  • The main handler function for the 'swap_quote' tool. Validates input parameters, calls poolService.getSwapQuote to retrieve the quote, formats it as a markdown text response, and returns it in the expected MCP format.
    async function swapQuoteTool(args, poolService) {
      const { poolAddress, fromMint, toMint, amount, slippage = 0.5 } = args;
    
      if (!poolAddress || !fromMint || !toMint || !amount) {
        throw new Error("poolAddress, fromMint, toMint, and amount are required");
      }
    
      if (amount <= 0) {
        throw new Error("Amount must be greater than 0");
      }
    
      if (slippage < 0 || slippage > 100) {
        throw new Error("Slippage must be between 0 and 100");
      }
    
      try {
        const quote = await poolService.getSwapQuote(
          poolAddress,
          fromMint,
          toMint,
          amount,
          slippage
        );
    
        const quoteText =
          `**Swap Quote**\n\n` +
          `**Input:**\n` +
          `- Pool: ${poolAddress}\n` +
          `- From: ${fromMint.slice(0, 8)}...\n` +
          `- To: ${toMint.slice(0, 8)}...\n` +
          `- Amount: ${amount}\n\n` +
          `**Output:**\n` +
          `- Expected Output: ${quote.outputAmount}\n` +
          `- Minimum Output (with slippage): ${quote.minimumOutputAmount}\n` +
          `- Price Impact: ${quote.priceImpact.toFixed(4)}%\n` +
          `- Fee: ${quote.fee}\n` +
          `- Slippage Tolerance: ${quote.slippage}%\n\n` +
          `**Rate:** 1 token = ${(quote.outputAmount / amount).toFixed(6)} tokens`;
    
        return {
          content: [
            {
              type: "text",
              text: quoteText,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get swap quote: ${error.message}`);
      }
    }
    module.exports = { swapQuoteTool };
  • The input schema and description for the 'swap_quote' tool, registered in the ListTools response.
    {
      name: "swap_quote",
      description:
        "Get swap quote for token exchange including price impact, fees, and minimum output amount with slippage.",
      inputSchema: {
        type: "object",
        properties: {
          poolAddress: {
            type: "string",
            description: "Pool address for the swap",
          },
          fromMint: {
            type: "string",
            description: "Source token mint address",
          },
          toMint: {
            type: "string",
            description: "Destination token mint address",
          },
          amount: {
            type: "number",
            description: "Amount to swap (in token decimals)",
          },
          slippage: {
            type: "number",
            description: "Slippage tolerance (0-100, default 0.5)",
            default: 0.5,
          },
        },
        required: ["poolAddress", "fromMint", "toMint", "amount"],
      },
    },
  • src/index.js:168-170 (registration)
    Registration of the 'swap_quote' tool in the CallToolRequestSchema handler switch statement, dispatching calls to the swapQuoteTool function.
    case "swap_quote":
      return await swapQuoteTool(args, this.poolService);
  • Helper method in SarosPoolService that computes the swap quote (mock implementation used by the tool handler).
    async getSwapQuote(poolAddress, fromMint, toMint, amount, slippage = 0.5) {
      const rate = 1.5;
      const outputAmount = amount * rate;
      return {
        inputAmount: amount,
        outputAmount,
        minimumOutputAmount: outputAmount * (1 - slippage / 100),
        priceImpact: 0.15,
        fee: amount * 0.0025,
        slippage,
      };
    }
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. It mentions the quote includes 'price impact, fees, and minimum output amount with slippage' which gives some output context, but doesn't describe whether this is a read-only operation, potential rate limits, authentication requirements, or what happens if parameters are invalid. For a financial tool with no annotations, this is insufficient.

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, efficient sentence that front-loads the core purpose and includes key output details. Every word earns its place with no redundancy or unnecessary elaboration. It's appropriately sized for the tool's complexity.

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 financial swap quote tool with no annotations and no output schema, the description is incomplete. It mentions what the quote includes but doesn't explain the return format, error conditions, or important behavioral aspects like whether this is a simulation or requires blockchain interaction. The 100% schema coverage helps, but the overall context remains inadequate.

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 the schema already documents all 5 parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'slippage' in the context of the quote output, but doesn't provide additional parameter semantics. Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose: 'Get swap quote for token exchange' specifies the verb (get) and resource (swap quote). It distinguishes from siblings by focusing on swap quotes rather than positions, analytics, or rebalancing. However, it doesn't explicitly differentiate from hypothetical alternative quote tools.

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 alternatives. It doesn't mention prerequisites, when-not-to-use scenarios, or compare with other tools. The context signals show siblings like get_farm_positions and simulate_rebalance, but the description offers no comparative guidance.

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/Pavilion-devs/saros-mcp-server'

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