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;
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool gets 'current' prices, implying real-time data, but doesn't specify data sources, update frequency, rate limits, or error handling. For a tool with zero annotation coverage, this leaves significant gaps in understanding its operational behavior.

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, clear sentence with no wasted words. It front-loads the essential information ('Get current gas prices in Gwei'), making it immediately actionable. Every part of the sentence earns its place by specifying the action, timeliness, resource, and unit.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is adequate but has clear gaps. It covers the basic purpose but lacks details on behavioral traits (e.g., data freshness, network context) and usage guidelines. For a tool that likely interacts with blockchain data, more context on reliability or scope would improve completeness.

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?

The tool has 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, focusing instead on the tool's output. A baseline of 4 is applied for zero-parameter tools, as it avoids unnecessary complexity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('current gas prices in Gwei'), making the tool's purpose immediately understandable. It distinguishes from siblings by focusing on gas prices rather than balances, ABIs, ENS names, or transaction data. However, it doesn't specify the scope (e.g., network, location) or differentiate from potential similar tools not in the sibling list, preventing a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context (e.g., for transaction planning), or exclusions (e.g., historical prices). While the tool's name and purpose imply usage for real-time gas price queries, this is only implied, not explicitly stated.

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

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