Skip to main content
Glama

DeFi Trading Agent MCP Server

by edkdev

get_gasless_price

Retrieve indicative prices for gasless token swaps, enabling cost-efficient trades across multiple blockchains without gas fees. Essential for DeFi trading agents.

Instructions

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

Input Schema

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

Input Schema (JSON Schema)

{ "properties": { "buyToken": { "description": "Contract address of token to buy", "type": "string" }, "chainId": { "description": "Blockchain ID (e.g., 8453 for Base)", "type": "integer" }, "sellAmount": { "description": "Amount of sellToken in base units", "type": "string" }, "sellToken": { "description": "Contract address of token to sell", "type": "string" }, "slippageBps": { "description": "Maximum acceptable slippage in basis points (optional, min: 30)", "type": "integer" }, "taker": { "description": "Address executing the trade (optional)", "type": "string" } }, "required": [ "chainId", "buyToken", "sellToken", "sellAmount" ], "type": "object" }

Implementation Reference

  • Primary handler for the 'get_gasless_price' tool. Validates input parameters (chainId, buyToken, sellToken, sellAmount) and delegates to AgService to fetch the gasless price from the aggregator API, 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, specifying parameters, types, descriptions, and required fields. Part of the tool registration 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:633-668 (registration)
    Tool registration in the MCP server's ListToolsRequestHandler, including name, description, and input schema for 'get_gasless_price'.
    { 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)
    Dispatch handler in CallToolRequestHandler switch statement that routes 'get_gasless_price' calls to toolService.getGaslessPrice.
    case TOOL_NAMES.GET_GASLESS_PRICE: result = await toolService.getGaslessPrice(args); break;
  • Supporting utility in AgService that performs the actual HTTP request to the aggregator API endpoint /api/swap/gasless/price to retrieve the gasless price data.
    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}`); } }

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