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

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