Skip to main content
Glama

get_chain_id

Retrieve the unique chain ID for a specified blockchain network to enable proper network configuration and transaction routing.

Instructions

Get the chain ID for a given chain name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_nameYesThe name of the chain to get the chain ID for

Implementation Reference

  • The main handler function for the get_chain_id tool. It extracts the chain_name from the request, looks it up in the chainIdMapping, and returns a text response with the chain ID or an error if not found.
    async function handleGetChainId(req: any) {
        const chainName = req.params.arguments.chain_name;
    
        if (chainIdMapping[chainName] != null) {
            return {
                content: [
                    {
                        type: "text",
                        text: `Chain ID for ${chainName}: ${chainIdMapping[chainName]}`,
                    },
                ]
            };
        } else {
            return {
                content: [
                    {
                        type: "text",
                        text: `Chain ${chainName} not found`
                    }
                ]
            };
        }
    }
  • ToolDefinition object defining the name, description, and input schema for the get_chain_id tool.
    const getChainId: ToolDefinition = {
        name: "get_chain_id",
        description: "Get the chain ID for a given chain name",
        inputSchema: {
            type: "object",
            properties: {
                chain_name: {
                    type: "string",
                    description: "The name of the chain to get the chain ID for"
                }
            },
            required: ["chain_name"]
        }
    };
  • Static mapping of chain names to their corresponding chain IDs, used by the get_chain_id handler to resolve chain_names to numeric IDs.
    const chainIdMapping: { [key: string]: number } = {
        "Ethereum Mainnet": 1,
        "Sepolia Testnet": 11155111,
        "Holesky Testnet": 17000,
        "Abstract Mainnet": 2741,
        "Abstract Sepolia Testnet": 11124,
        "ApeChain Curtis Testnet": 33111,
        "ApeChain Mainnet": 33139,
        "Arbitrum Nova Mainnet": 42170,
        "Arbitrum One Mainnet": 42161,
        "Arbitrum Sepolia Testnet": 421614,
        "Avalanche C-Chain": 43114,
        "Avalanche Fuji Testnet": 43113,
        "Base Mainnet": 8453,
        "Base Sepolia Testnet": 84532,
        "Berachain Mainnet": 80094,
        "BitTorrent Chain Mainnet": 199,
        "BitTorrent Chain Testnet": 1028,
        "Blast Mainnet": 81457,
        "Blast Sepolia Testnet": 168587773,
        "BNB Smart Chain Mainnet": 56,
        "BNB Smart Chain Testnet": 97,
        "Celo Alfajores Testnet": 44787,
        "Celo Mainnet": 42220,
        "Cronos Mainnet": 25,
        "Fraxtal Mainnet": 252,
        "Fraxtal Testnet": 2522,
        "Gnosis": 100,
        "Linea Mainnet": 59144,
        "Linea Sepolia Testnet": 59141,
        "Mantle Mainnet": 5000,
        "Mantle Sepolia Testnet": 5003,
        "Moonbase Alpha Testnet": 1287,
        "Moonbeam Mainnet": 1284,
        "Moonriver Mainnet": 1285,
        "OP Mainnet": 10,
        "OP Sepolia Testnet": 11155420,
        "Polygon Amoy Testnet": 80002,
        "Polygon Mainnet": 137,
        "Polygon zkEVM Cardona Testnet": 2442,
        "Polygon zkEVM Mainnet": 1101,
        "Scroll Mainnet": 534352,
        "Scroll Sepolia Testnet": 534351,
        "Sonic Blaze Testnet": 57054,
        "Sonic Mainnet": 146,
        "Sophon Mainnet": 50104,
        "Sophon Sepolia Testnet": 531050104,
        "Taiko Hekla L2 Testnet": 167009,
        "Taiko Mainnet": 167000,
        "Unichain Mainnet": 130,
        "Unichain Sepolia Testnet": 1301,
        "WEMIX3.0 Mainnet": 1111,
        "WEMIX3.0 Testnet": 1112,
        "World Mainnet": 480,
        "World Sepolia Testnet": 4801,
        "Xai Mainnet": 660279,
        "Xai Sepolia Testnet": 37714555429,
        "XDC Apothem Testnet": 51,
        "XDC Mainnet": 50,
        "zkSync Mainnet": 324,
        "zkSync Sepolia Testnet": 300,
    };
  • index.ts:216-223 (registration)
    toolDefinitions object where getChainId is registered by name, used for MCP capabilities and listTools.
    const toolDefinitions: { [key: string]: ToolDefinition } = {
        [getFilteredRpcList.name]: getFilteredRpcList,
        [getChainId.name]: getChainId,
        [getTotalSupply.name]: getTotalSupply,
        [getTokenBalance.name]: getTokenBalance,
        [getTokenHolders.name]: getTokenHolders,
        [getTokenHoldersCount.name]: getTokenHoldersCount
    };
  • index.ts:481-482 (registration)
    Switch case in callToolHandler that routes calls to get_chain_id to the handleGetChainId function.
    case getChainId.name:
        return await handleGetChainId(req);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'gets' data, implying a read-only operation, but doesn't clarify aspects like error handling (e.g., what happens if the chain name is invalid), performance (e.g., speed or rate limits), or output format. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. It is front-loaded with the core purpose ('Get the chain ID'), making it easy to understand at a glance. Every part of the sentence contributes directly to explaining the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one parameter, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks details on behavioral traits, usage context, or output. For a simple lookup tool, this might suffice, but it doesn't provide a complete picture for an agent to use it effectively without additional inference.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the parameter 'chain_name' fully documented. The description adds no additional semantic meaning beyond what the schema provides (e.g., it doesn't explain what a 'chain name' entails or provide examples). Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('chain ID'), and specifies the input ('for a given chain name'). However, it doesn't differentiate this tool from its siblings (like get_filtered_rpc_list or get_token_balance), which all appear to be blockchain-related queries but serve different functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, exclusions, or specific contexts for usage, nor does it reference sibling tools. The agent must infer usage based solely on the tool name and description without explicit direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/septemhill/etherscan-mcp'

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