Skip to main content
Glama
edkdev

DeFi Trading Agent MCP Server

by edkdev

get_gasless_price

Calculate indicative prices for token swaps without gas fees by specifying chain, tokens, and amounts to enable cost-efficient DeFi trading.

Instructions

Get indicative price for a gasless token swap (no gas fees required)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdYesBlockchain ID (e.g., 8453 for Base)
buyTokenYesContract address of token to buy
sellTokenYesContract address of token to sell
sellAmountYesAmount of sellToken in base units
takerNoAddress executing the trade (optional)
slippageBpsNoMaximum acceptable slippage in basis points (optional, min: 30)

Implementation Reference

  • Primary MCP tool handler for get_gasless_price. Validates parameters and delegates to AgService.getGaslessPrice, returning formatted response.
    async getGaslessPrice(params) {
      const { chainId, buyToken, sellToken, sellAmount } = params;
    
      if (!chainId || !buyToken || !sellToken || !sellAmount) {
        throw new Error(
          "Missing required parameters: chainId, buyToken, sellToken, sellAmount"
        );
      }
    
      const result = await this.agg.getGaslessPrice(params);
    
      return {
        message: "Gasless swap price retrieved successfully",
        data: result,
        note: "This is a gasless swap - no ETH needed for gas fees",
      };
    }
  • Input schema definition for the get_gasless_price tool, registered in ListToolsRequestHandler.
      name: TOOL_NAMES.GET_GASLESS_PRICE,
      description:
        "Get indicative price for a gasless token swap (no gas fees required)",
      inputSchema: {
        type: "object",
        properties: {
          chainId: {
            type: "integer",
            description: "Blockchain ID (e.g., 8453 for Base)",
          },
          buyToken: {
            type: "string",
            description: "Contract address of token to buy",
          },
          sellToken: {
            type: "string",
            description: "Contract address of token to sell",
          },
          sellAmount: {
            type: "string",
            description: "Amount of sellToken in base units",
          },
          taker: {
            type: "string",
            description: "Address executing the trade (optional)",
          },
          slippageBps: {
            type: "integer",
            description:
              "Maximum acceptable slippage in basis points (optional, min: 30)",
          },
        },
        required: ["chainId", "buyToken", "sellToken", "sellAmount"],
      },
    },
  • src/index.js:1138-1140 (registration)
    Tool dispatch/registration in the main CallToolRequestHandler switch statement.
    case TOOL_NAMES.GET_GASLESS_PRICE:
      result = await toolService.getGaslessPrice(args);
      break;
  • Supporting helper method in AgService that makes the actual API call to the aggregator's gasless price endpoint.
    async getGaslessPrice(params) {
      try {
        const queryParams = new URLSearchParams(params);
        const response = await fetch(`${this.baseUrl}/api/swap/gasless/price?${queryParams}`);
        
        if (!response.ok) {
          throw new Error(`HTTP ${response.status}: ${response.statusText}`);
        }
        
        const data = await response.json();
        
        if (!data.success) {
          throw new Error(data.error || 'Gasless price request failed');
        }
        
        return data.data;
      } catch (error) {
        throw new Error(`Failed to get gasless price: ${error.message}`);
      }
    }
  • src/constants.js:11-11 (registration)
    Constant defining the tool name string used throughout the codebase.
    GET_GASLESS_PRICE: "get_gasless_price",
Behavior2/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. It states the tool provides an 'indicative price' (implying non-binding, estimate) and mentions 'no gas fees required', but fails to disclose critical behaviors like whether this is a read-only operation, potential rate limits, authentication needs, or what 'indicative' entails (e.g., time validity, accuracy). This leaves significant gaps for a tool interacting with financial data.

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 ('Get indicative price') and adds qualifying context ('gasless token swap', 'no gas fees required') without any wasted words. Every element earns its place.

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 tool with 6 parameters, no annotations, and no output schema, the description is incomplete. It lacks behavioral details (e.g., read-only status, error conditions), doesn't explain the 'indicative' nature of the output, and provides no guidance on interpreting results. Given the complexity and financial context, more completeness is needed.

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 fully documents all 6 parameters. The description adds no parameter-specific information beyond what's in the schema—it doesn't explain relationships between parameters (e.g., how sellAmount interacts with buyToken) or provide additional context. Baseline 3 is appropriate when schema does all the work.

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 specific action ('Get indicative price') for a specific resource ('gasless token swap') and distinguishes it from siblings by emphasizing 'no gas fees required'—differentiating it from tools like get_swap_price or get_swap_quote that likely involve gas fees.

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

Usage Guidelines3/5

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

The description implies usage context ('gasless token swap') but provides no explicit guidance on when to use this tool versus alternatives like get_gasless_quote or get_swap_price. It mentions 'no gas fees required' which hints at a use case, but lacks clear when/when-not instructions or named 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/edkdev/defi-trading-mcp'

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