Skip to main content
Glama

estimate-fee-per-gas

Calculate optimal gas fees for blockchain transactions to ensure timely inclusion in the next block using MetaMask MCP server.

Instructions

Estimate for the fees per gas (in wei) for a transaction to be likely included in the next block.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNoID of chain to use when fetching data.
formatUnitsNoUnits to use when formatting result.gwei

Implementation Reference

  • The handler function that executes the tool by calling `estimateFeesPerGas` from wagmi/core with the provided config and arguments, then stringifies and returns the result as text content.
    execute: async (args) => {
      const result = await estimateFeesPerGas(wagmiConfig, args);
      return {
        content: [
          {
            type: "text",
            text: JSONStringify(result),
          },
        ],
      };
    },
  • Input schema using Zod defining optional `chainId` (number) and `formatUnits` (enum: 'ether'|'gwei'|'wei', default 'gwei').
    parameters: z.object({
      chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."),
      formatUnits: z.enum(["ether", "gwei", "wei"]).default("gwei").optional().describe("Units to use when formatting result."),
    }),
  • Exported registration function that adds the 'estimate-fee-per-gas' tool to the FastMCP server, including name, description, schema, and handler.
    export function registerEstimateFeePerGasTools(server: FastMCP, wagmiConfig: Config): void {
      server.addTool({
        name: "estimate-fee-per-gas",
        description: "Estimate for the fees per gas (in wei) for a transaction to be likely included in the next block.",
        parameters: z.object({
          chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."),
          formatUnits: z.enum(["ether", "gwei", "wei"]).default("gwei").optional().describe("Units to use when formatting result."),
        }),
        execute: async (args) => {
          const result = await estimateFeesPerGas(wagmiConfig, args);
          return {
            content: [
              {
                type: "text",
                text: JSONStringify(result),
              },
            ],
          };
        },
      });
    };
  • Invocation of the tool-specific registration function within the central registerTools function.
    registerEstimateFeePerGasTools(server, wagmiConfig);
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 mentions the tool estimates fees for likely inclusion in the next block, which is useful, but lacks details on rate limits, error handling, network dependencies, or output format. For a tool with no annotations, this leaves significant gaps in understanding its behavior and constraints.

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, well-structured sentence that efficiently conveys the core purpose without unnecessary words. It is front-loaded with the main action ('Estimate for the fees per gas') and includes essential context ('in wei', 'for a transaction to be likely included in the next block'), making it highly concise and effective.

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?

Given the complexity of fee estimation in blockchain contexts, no annotations, and no output schema, the description is incomplete. It lacks information on what the output includes (e.g., base fee, priority fee), how estimates are derived, potential inaccuracies, or dependencies on network conditions. For a tool with significant contextual needs, this description does not provide sufficient completeness.

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

Parameters3/5

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

The input schema has 100% description coverage, with clear documentation for both parameters ('chainId' and 'formatUnits'). The description does not add any parameter-specific semantics beyond what the schema provides, such as explaining how 'chainId' affects the estimate or the implications of 'formatUnits'. Since schema coverage is high, the baseline score of 3 is appropriate, as the description does not compensate but also does not detract.

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 tool's purpose: 'Estimate for the fees per gas (in wei) for a transaction to be likely included in the next block.' It specifies the verb ('estimate'), resource ('fees per gas'), and context ('for a transaction to be likely included in the next block'). However, it does not explicitly differentiate from sibling tools like 'estimate-gas', which estimates gas usage rather than fees, leaving room for confusion.

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 minimal guidance on when to use this tool. It implies usage when estimating fees for transaction inclusion, but does not specify alternatives (e.g., vs. 'estimate-gas' for gas usage) or exclusions (e.g., not for historical data). No explicit when-to-use or when-not-to-use instructions are given, relying on implicit context.

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/Xiawpohr/metamask-mcp'

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