Skip to main content
Glama

get-latest-block

Retrieve the most recent block data from the Monad testnet for monitoring transactions, smart contracts, and network activity using the MCP server.

Instructions

Get the latest block on Monad testnet

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {}, "type": "object" }

Implementation Reference

  • The async handler function that fetches the latest block using publicClient.getBlock(), extracts key properties (number, hash, timestamp, tx count, parentHash, gasUsed, gasLimit), formats them into a markdown-like text response, and handles errors by returning an error message.
    async () => { try { const block = await publicClient.getBlock(); 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 latest block. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
  • Direct registration of the 'get-latest-block' tool on the MCP server, including name, description, empty input schema ({}), and inline handler function.
    server.tool( "get-latest-block", "Get the latest block on Monad testnet", {}, async () => { try { const block = await publicClient.getBlock(); 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 latest block. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );
  • blockProvider function that calls getLatestBlockProvider(server) to register the get-latest-block tool (and get-block-by-number).
    export function blockProvider(server: McpServer) { getLatestBlockProvider(server); getBlockByNumberProvider(server); }
  • src/index.ts:27-27 (registration)
    Invocation of blockProvider during main server initialization to register block tools including 'get-latest-block'.
    blockProvider(server);
  • Provider function exported for use in block/index.ts, which registers the tool.
    export function getLatestBlockProvider(server: McpServer) { server.tool( "get-latest-block", "Get the latest block on Monad testnet", {}, async () => { try { const block = await publicClient.getBlock(); 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 latest block. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); }

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