get-block-number
Fetch the most recent blockchain block number to monitor network activity and verify transaction confirmations using MetaMask's secure wallet integration.
Instructions
Fetch the number of the most recent block seen.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | No | ID of chain to use when fetching data. |
Implementation Reference
- src/tools/get-block-number.ts:13-26 (handler)The handler function that fetches the latest block number using wagmi's getBlockNumber action, optionally for a specific chain, and returns it as a text response.execute: async (args) => { const chainId = args.chainId as typeof wagmiConfig["chains"][number]["id"]; const result = await getBlockNumber(wagmiConfig, { chainId, }); return { content: [ { type: "text", text: result.toString(), }, ], }; },
- src/tools/get-block-number.ts:10-12 (schema)Zod schema defining the optional chainId parameter for the tool.parameters: z.object({ chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }),
- src/tools/get-block-number.ts:6-28 (registration)The registration function for the get-block-number tool, which adds it to the FastMCP server with name, description, schema, and handler.export function registerGetBlockNumberTools(server: FastMCP, wagmiConfig: Config): void { server.addTool({ name: "get-block-number", description: "Fetch the number of the most recent block seen.", parameters: z.object({ chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }), execute: async (args) => { const chainId = args.chainId as typeof wagmiConfig["chains"][number]["id"]; const result = await getBlockNumber(wagmiConfig, { chainId, }); return { content: [ { type: "text", text: result.toString(), }, ], }; }, }); };
- src/tools/register-tools.ts:42-42 (registration)Call to registerGetBlockNumberTools within the overall registerTools function that sets up all tools.registerGetBlockNumberTools(server, wagmiConfig);
- src/index.ts:15-15 (registration)Top-level call to register all tools, including get-block-number, on the MCP server.registerTools(server, wagmiConfig);