Skip to main content
Glama

get_chain_info

Retrieve detailed chain information for specified networks like BSC, Ethereum, and Base using the bnbchain-mcp server. Input network name or chain ID to fetch data.

Instructions

Get chain information for a specific network

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkNoNetwork name (e.g. 'bsc', 'opbnb', 'ethereum', 'base', etc.) or chain ID. Supports others main popular networks. Defaults to BSC mainnet.bsc

Implementation Reference

  • Registration of the 'get_chain_info' tool including inline handler function that retrieves chainId, blockNumber, and rpcUrl using imported services.
    server.tool( "get_chain_info", "Get chain information for a specific network", { network: defaultNetworkParam }, async ({ network }) => { try { const chainId = await services.getChainId(network) const blockNumber = await services.getBlockNumber(network) const rpcUrl = getRpcUrl(network) return mcpToolRes.success({ network, chainId, blockNumber: blockNumber.toString(), rpcUrl }) } catch (error) { return mcpToolRes.error(error, "fetching chain info") } } )
  • Zod schema definition for the 'network' input parameter used in get_chain_info tool.
    export const defaultNetworkParam = z .string() .describe( "Network name (e.g. 'bsc', 'opbnb', 'ethereum', 'base', etc.) or chain ID. Supports others main popular networks. Defaults to BSC mainnet." ) .default("bsc")
  • Helper function to get the current block number for a given network using viem's public client.
    export async function getBlockNumber(network = "ethereum"): Promise<bigint> { const client = getPublicClient(network) return await client.getBlockNumber() }
  • Helper function to get the chain ID for a given network using viem's public client.
    export async function getChainId(network = "ethereum"): Promise<number> { const client = getPublicClient(network) const chainId = await client.getChainId() return Number(chainId) }

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/bnb-chain/bnbchain-mcp'

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