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
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | No | ID of chain to use when fetching data. | |
| formatUnits | No | Units to use when formatting result. | gwei |
Implementation Reference
- src/tools/estimate-fee-per-gas.ts:15-25 (handler)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."), }),
- src/tools/estimate-fee-per-gas.ts:7-27 (registration)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), }, ], }; }, }); };
- src/tools/register-tools.ts:38-38 (registration)Invocation of the tool-specific registration function within the central registerTools function.registerEstimateFeePerGasTools(server, wagmiConfig);