Skip to main content
Glama

get-block-info

Retrieve detailed block information from MantraChain blockchain by specifying block height and network name using the Model Context Protocol (MCP).

Instructions

Get block information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
heightNoOptional block height to query, defaults to latest block
networkNameYesName of the network to use - must first check what networks are available through the mantrachain-mcp server by accessing the networks resource `networks://all` before you pass this arguments

Implementation Reference

  • MCP server.tool registration for 'get-block-info', including description, input schema, and inline handler function.
    server.tool( "get-block-info", "Get block information from cometbft rpc", { networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."), height: z.number().optional().describe("Optional block height to query, defaults to latest block"), }, async ({ networkName, height }) => { await mantraClient.initialize(networkName); const currentBlockInfo = await mantraClient.getBlockInfo(height); return { content: [{type: "text", text: JSON.stringify(currentBlockInfo)}], }; } );
  • Input validation schema using Zod for networkName (validated against available networks) and optional height.
    { networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."), height: z.number().optional().describe("Optional block height to query, defaults to latest block"), },
  • Tool execution handler: initializes MantraClient for the specified network and retrieves block information, returning it as JSON text in MCP response format.
    async ({ networkName, height }) => { await mantraClient.initialize(networkName); const currentBlockInfo = await mantraClient.getBlockInfo(height); return { content: [{type: "text", text: JSON.stringify(currentBlockInfo)}], }; }
  • Supporting utility function in NetworkService that fetches block data via Comet38Client, processes and returns key block metadata (height, time, chainId, tx count, proposer, appHash). Called by MantraClient.getBlockInfo.
    async getBlockInfo(height?: number) { try { const blockData = height ? await this.cometClient.block(height) : await this.cometClient.block(); // Extract the most useful information return { height: blockData.block.header.height, time: blockData.block.header.time.toISOString(), chainId: blockData.block.header.chainId, numTxs: blockData.block.txs?.length || 0, proposer: Buffer.from(blockData.block.header.proposerAddress).toString('hex').toUpperCase(), appHash: Buffer.from(blockData.block.header.appHash).toString('hex').toUpperCase(), }; } catch (error) { throw new Error(`Failed to get current block info: ${error instanceof Error ? error.message : String(error)}`); } }

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/allthatjazzleo/mantrachain-mcp'

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