get-block-number
Retrieve the current block number for a specified blockchain to monitor network status and synchronize transactions.
Instructions
Get the block nunber of a chain
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get-block-number"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | No |
Implementation Reference
- The execute handler function that retrieves the current block number using Wagmi's getBlockNumber action and returns it as a text content block.
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(), }, ], } }, - Zod schema defining the optional chainId parameter for the tool.
parameters: z.object({ chainId: z.coerce.number().optional(), }), - packages/metamask-mcp/src/tools/get-block-number.ts:7-28 (registration)Registers the get-block-number tool on the FastMCP server instance, including name, description, schema, and handler.
server.addTool({ name: "get-block-number", description: "Get the block nunber of a chain", parameters: z.object({ chainId: z.coerce.number().optional(), }), 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(), }, ], } }, }); }; - packages/metamask-mcp/src/index.ts:45-45 (registration)Invokes the tool registration function on the main MCP server instance.
registerGetBlockNumberTools(server);