Skip to main content
Glama

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNo

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(),
    }),
  • 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(),
              },
            ],
          }
        },
      });
    };
  • Invokes the tool registration function on 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