Skip to main content
Glama

get_chain_info

Retrieve detailed EVM network information, including chain ID, network name, and compatibility details, for any EVM-compatible blockchain. Supports default Ethereum mainnet or specified networks.

Instructions

Get information about an EVM network

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkNoNetwork name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. Supports all EVM-compatible networks. Defaults to Ethereum mainnet.

Implementation Reference

  • The core handler function for the 'get_chain_info' tool. It resolves the network, fetches the chain ID, current block number, and RPC URL, then returns formatted JSON response or error.
    async ({ network = 'ethereum' }) => { try { const chainId = await services.getChainId(network); const blockNumber = await services.getBlockNumber(network); const rpcUrl = getRpcUrl(network); return { content: [ { type: 'text', text: JSON.stringify( { network, chainId, blockNumber: blockNumber.toString(), rpcUrl }, null, 2 ) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching chain info: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
  • Zod schema for input validation of the 'get_chain_info' tool, defining the optional 'network' parameter.
    network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. Supports all EVM-compatible networks. Defaults to Ethereum mainnet." ) },
  • Registration of the 'get_chain_info' tool on the MCP server within the registerEVMTools function.
    'get_chain_info', 'Get information about an EVM network', { network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. Supports all EVM-compatible networks. Defaults to Ethereum mainnet." ) }, async ({ network = 'ethereum' }) => { try { const chainId = await services.getChainId(network); const blockNumber = await services.getBlockNumber(network); const rpcUrl = getRpcUrl(network); return { content: [ { type: 'text', text: JSON.stringify( { network, chainId, blockNumber: blockNumber.toString(), rpcUrl }, null, 2 ) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching chain info: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
  • Helper function getBlockNumber used by the get_chain_info handler to fetch the latest block number.
    export async function getBlockNumber(network = 'ethereum'): Promise<bigint> { const client = getPublicClient(network); return await client.getBlockNumber(); }
  • Helper function getRpcUrl used by the get_chain_info handler to retrieve the RPC endpoint for the network.
    export function getRpcUrl( chainIdentifier: number | string = DEFAULT_CHAIN_ID ): string { const chainId = typeof chainIdentifier === 'string' ? resolveChainId(chainIdentifier) : chainIdentifier; return rpcUrlMap[chainId] || DEFAULT_RPC_URL; }

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/chulanpro5/evm-mcp-server'

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