Skip to main content
Glama

get-block-by-number

Retrieve specific block details by providing the block number on the Monad testnet using the Monad MCP Server. Simplify interactions with blockchain data for AI models and development workflows.

Instructions

Get a block by number on Monad testnet

Input Schema

NameRequiredDescriptionDefault
numberYesThe block number to retrieve

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "number": { "description": "The block number to retrieve", "type": "string" } }, "required": [ "number" ], "type": "object" }

Implementation Reference

  • The handler function that retrieves the block by number using publicClient.getBlock, formats key block details into a text response, and handles errors.
    async (args) => { try { const block = await publicClient.getBlock({ blockNumber: BigInt(args.number) }); return { content: [ { type: "text", text: `Block Number: ${block.number} Hash: ${block.hash} Timestamp: ${block.timestamp} Transaction Count: ${block.transactions.length} Parent Hash: ${block.parentHash} Gas Used: ${block.gasUsed} Gas Limit: ${block.gasLimit}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to retrieve the block. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
  • Input schema defining the 'number' parameter as a string using Zod.
    { "number": z.string().describe("The block number to retrieve"), },
  • The provider function that registers the 'get-block-by-number' tool on the MCP server, including name, description, schema, and handler.
    export function getBlockByNumberProvider(server: McpServer) { server.tool( "get-block-by-number", "Get a block by number on Monad testnet", { "number": z.string().describe("The block number to retrieve"), }, async (args) => { try { const block = await publicClient.getBlock({ blockNumber: BigInt(args.number) }); return { content: [ { type: "text", text: `Block Number: ${block.number} Hash: ${block.hash} Timestamp: ${block.timestamp} Transaction Count: ${block.transactions.length} Parent Hash: ${block.parentHash} Gas Used: ${block.gasUsed} Gas Limit: ${block.gasLimit}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to retrieve the block. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); }
  • Intermediate registration function that invokes the getBlockByNumberProvider among other block tools.
    export function blockProvider(server: McpServer) { getLatestBlockProvider(server); getBlockByNumberProvider(server); }
  • src/index.ts:27-27 (registration)
    Top-level call to register all block tools, including 'get-block-by-number', during server initialization.
    blockProvider(server);

Other Tools

Related Tools

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/lispking/monad-mcp-server'

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