Skip to main content
Glama
get-block-number.ts848 B
import type { Config } from "@wagmi/core"; import type { FastMCP } from "fastmcp"; import { getBlockNumber } from "@wagmi/core"; import { z } from "zod"; 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(), }, ], }; }, }); };

Implementation Reference

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/metamask-mcp'

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