Skip to main content
Glama

getNetwork

Retrieve blockchain network details including chain ID, native token, and RPC URL for Ethereum-compatible networks to configure wallet connections and interactions.

Instructions

Get detailed information about a specific blockchain network. This provides the network's chain ID, native token, and RPC URL that can be used with other Ethereum tools. This network name can be used as the 'provider' parameter in other tools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe name of the network to get details for (case-insensitive, e.g., 'ethereum', 'polygon', 'arbitrum')

Implementation Reference

  • Handler function for 'getNetwork' tool: matches network name case-insensitively against DEFAULT_PROVIDERS, retrieves config from networkList, returns JSON with name, chainId, nativeToken, rpcUrl, explorer or error with available networks list.
    async ({ name }) => { try { // Find network by name (case insensitive) const networkName = DEFAULT_PROVIDERS.find( provider => provider.toLowerCase() === name.toLowerCase() ); if (!networkName || !(networkName in networkList)) { // Get list of available networks for helpful error message const availableNetworks = DEFAULT_PROVIDERS .filter(n => n in networkList) .join(', '); return createErrorResponse( new Error(`Network '${name}' not found. Available networks are: ${availableNetworks}`), 'getting network information' ); } const networkInfo = networkList[networkName as NetworkName]; const data = { name: networkName, chainId: networkInfo.chainId, nativeToken: networkInfo.currency, rpcUrl: networkInfo.RPC, explorer: networkInfo.explorer || '' }; return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { return createErrorResponse(error, 'getting network information'); } }
  • Registers the 'getNetwork' MCP tool with server.tool(), including tool name, description, input schema (name: string), and inline handler function.
    server.tool( "getNetwork", "Get detailed information about a specific blockchain network. This provides the network's chain ID, native token, and RPC URL that can be used with other Ethereum tools. This network name can be used as the 'provider' parameter in other tools.", { name: z.string().describe("The name of the network to get details for (case-insensitive, e.g., 'ethereum', 'polygon', 'arbitrum')") }, async ({ name }) => { try { // Find network by name (case insensitive) const networkName = DEFAULT_PROVIDERS.find( provider => provider.toLowerCase() === name.toLowerCase() ); if (!networkName || !(networkName in networkList)) { // Get list of available networks for helpful error message const availableNetworks = DEFAULT_PROVIDERS .filter(n => n in networkList) .join(', '); return createErrorResponse( new Error(`Network '${name}' not found. Available networks are: ${availableNetworks}`), 'getting network information' ); } const networkInfo = networkList[networkName as NetworkName]; const data = { name: networkName, chainId: networkInfo.chainId, nativeToken: networkInfo.currency, rpcUrl: networkInfo.RPC, explorer: networkInfo.explorer || '' }; return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { return createErrorResponse(error, 'getting network information'); } } );
  • Zod input schema for getNetwork tool: requires 'name' parameter as string with description.
    { name: z.string().describe("The name of the network to get details for (case-insensitive, e.g., 'ethereum', 'polygon', 'arbitrum')") },
  • Top-level registration call to registerNetworkTools(server), which includes the getNetwork tool registration.
    registerNetworkTools(server);

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/crazyrabbitLTC/mcp-ethers-server'

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