Skip to main content
Glama
5ajaki
by 5ajaki

get-gas-prices

Retrieve current Ethereum network gas prices in Gwei to optimize transaction costs and timing.

Instructions

Get current gas prices in Gwei

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Executes the get-gas-prices tool by calling EtherscanService.getGasOracle(), formatting the safe, standard, and fast gas prices into a text response.
    if (name === "get-gas-prices") { try { const prices = await etherscanService.getGasOracle(); const response = `Current Gas Prices:\n` + `Safe Low: ${prices.safeGwei} Gwei\n` + `Standard: ${prices.proposeGwei} Gwei\n` + `Fast: ${prices.fastGwei} Gwei`; return { content: [{ type: "text", text: response }], }; } catch (error) { throw error; } }
  • Defines the tool schema with name, description, and empty input schema (no parameters required).
    { name: "get-gas-prices", description: "Get current gas prices in Gwei", inputSchema: { type: "object", properties: {}, }, }, {
  • src/server.ts:63-163 (registration)
    Registers the get-gas-prices tool in the list of available tools returned by ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "check-balance", description: "Check the ETH balance of an Ethereum address", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address (0x format)", pattern: "^0x[a-fA-F0-9]{40}$", }, }, required: ["address"], }, }, { name: "get-transactions", description: "Get recent transactions for an Ethereum address", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address (0x format)", pattern: "^0x[a-fA-F0-9]{40}$", }, limit: { type: "number", description: "Number of transactions to return (max 100)", minimum: 1, maximum: 100, }, }, required: ["address"], }, }, { name: "get-token-transfers", description: "Get ERC20 token transfers for an Ethereum address", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address (0x format)", pattern: "^0x[a-fA-F0-9]{40}$", }, limit: { type: "number", description: "Number of transfers to return (max 100)", minimum: 1, maximum: 100, }, }, required: ["address"], }, }, { name: "get-contract-abi", description: "Get the ABI for a smart contract", inputSchema: { type: "object", properties: { address: { type: "string", description: "Contract address (0x format)", pattern: "^0x[a-fA-F0-9]{40}$", }, }, required: ["address"], }, }, { name: "get-gas-prices", description: "Get current gas prices in Gwei", inputSchema: { type: "object", properties: {}, }, }, { name: "get-ens-name", description: "Get the ENS name for an Ethereum address", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address (0x format)", pattern: "^0x[a-fA-F0-9]{40}$", }, }, required: ["address"], }, }, ], }; });
  • Core helper function that fetches current gas oracle data from Etherscan API and parses safeGasPrice, ProposeGasPrice, and FastGasPrice.
    async getGasOracle(): Promise<GasPrice> { try { // Get current gas prices const result = await fetch( `https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=${this.provider.apiKey}` ); const data = await result.json(); if (data.status !== "1" || !data.result) { throw new Error(data.message || "Failed to fetch gas prices"); } return { safeGwei: data.result.SafeGasPrice, proposeGwei: data.result.ProposeGasPrice, fastGwei: data.result.FastGasPrice }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get gas prices: ${error.message}`); } throw error; } }

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/5ajaki/mcp-etherscan-server'

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