Skip to main content
Glama
5ajaki

MCP Etherscan Server

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;
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and the description omits behavioral details like data freshness, polling limits, or whether it returns a single value or multiple fee levels. For a zero-parameter tool, the description carries full burden and leaves ambiguity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise single sentence, no wasted words. However, could have added output format without harming conciseness.

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?

Despite low complexity and no parameters, the lack of output schema means the description should clarify what 'gas prices' includes (e.g., low/avg/high). Fails to fully inform an agent about return format.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters exist, so schema coverage is 100%. No additional param info needed; the description appropriately has no redundant details.

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 action (get), the resource (current gas prices), and the unit (Gwei). It effectively distinguishes from sibling tools like check-balance or get-transactions, which are unrelated.

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?

No explicit guidance on when to use or alternatives, but the tool's simplicity and unique purpose among siblings make usage straightforward. Lacks when-not or context for multi-fee levels.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.