Skip to main content
Glama

get-block-number

Retrieve the current block number of a specified blockchain using chain ID. Enable AI-driven blockchain interactions securely via MetaMask integration, without exposing private keys.

Instructions

Get the block nunber of a chain

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNo

Implementation Reference

  • The execute function that retrieves the current block number using wagmi's getBlockNumber action, optionally for a specific chainId, and returns it as text content.
    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 for the tool parameters: optional chainId (number).
    parameters: z.object({ chainId: z.coerce.number().optional(), }),
  • Registers the get-block-number tool on the FastMCP server, 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(), }, ], } }, });
  • Calls the registration function to add the get-block-number tool to the main MCP server instance.
    registerGetBlockNumberTools(server);

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/mcpilot'

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