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",

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