Skip to main content
Glama
get-latest-block.ts1.56 kB
/** * Tool implementation for getting the latest block on Monad testnet */ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { publicClient } from "../../config/server"; /** * Register the latest block tool with the MCP server */ 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)}`, }, ], }; } } ); }

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

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