Skip to main content
Glama

get_chain_info

Retrieve configuration and status details for specific blockchain networks to support cross-chain trading operations on Paloma DEX.

Instructions

Get detailed information about a specific chain.

Args:
    chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)

Returns:
    JSON string with chain configuration and status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_idYes

Implementation Reference

  • The handler function for the 'get_chain_info' tool. It is decorated with @mcp.tool() for automatic registration in FastMCP. Retrieves chain configuration from CHAIN_CONFIGS, checks Web3 connection status, fetches latest block number, and returns formatted JSON with chain details.
    @mcp.tool()
    async def get_chain_info(ctx: Context, chain_id: str) -> str:
        """Get detailed information about a specific chain.
        
        Args:
            chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)
        
        Returns:
            JSON string with chain configuration and status.
        """
        try:
            paloma_ctx = ctx.request_context.lifespan_context
            
            if chain_id not in CHAIN_CONFIGS:
                available_chains = [str(k) for k in CHAIN_CONFIGS.keys()]
                return f"Error: Unsupported chain ID '{chain_id}'. Available: {available_chains}"
            
            config = CHAIN_CONFIGS[chain_id]
            
            chain_info = {
                "chain_id": config.chain_id,
                "name": config.name,
                "rpc_url": config.rpc_url,
                "explorer_url": config.explorer_url,
                "gas_price_gwei": config.gas_price_gwei,
                "contracts": {
                    "pusd_token": config.pusd_token or "Not configured",
                    "pusd_connector": config.pusd_connector or "Not configured",
                    "etf_connector": config.etf_connector or "Not configured"
                }
            }
            
            # Add connection status
            if chain_id in paloma_ctx.web3_clients:
                try:
                    web3 = paloma_ctx.web3_clients[chain_id]
                    latest_block = web3.eth.get_block('latest')
                    chain_info["status"] = "connected"
                    chain_info["latest_block"] = latest_block.number
                except Exception as e:
                    chain_info["status"] = f"connection_error: {str(e)}"
            else:
                chain_info["status"] = "not_connected"
            
            return json.dumps(chain_info, indent=2)
            
        except Exception as e:
            logger.error(f"Error getting chain info: {e}")
            return f"Error getting chain info: {str(e)}"
  • Global CHAIN_CONFIGS dictionary mapping ChainID enums to ChainConfig dataclasses. Provides RPC URLs, contract addresses (PUSD, connectors), explorer URLs, and gas prices for all 7 supported EVM chains. Directly used by get_chain_info to populate chain_info dict.
    CHAIN_CONFIGS = {
        ChainID.ETHEREUM_MAIN: ChainConfig(
            chain_id=1,
            name="Ethereum",
            rpc_url="https://eth.llamarpc.com",
            pusd_token=os.getenv("PUSD_TOKEN_ETH", ""),
            pusd_connector=os.getenv("PUSD_CONNECTOR_ETH", ""),
            etf_connector=os.getenv("ETF_CONNECTOR_ETH", ""),
            explorer_url="https://etherscan.io",
            gas_price_gwei=30
        ),
        ChainID.ARBITRUM_MAIN: ChainConfig(
            chain_id=42161,
            name="Arbitrum One",
            rpc_url="https://arb1.arbitrum.io/rpc",
            pusd_token=os.getenv("PUSD_TOKEN_ARB", ""),
            pusd_connector=os.getenv("PUSD_CONNECTOR_ARB", ""),
            etf_connector=os.getenv("ETF_CONNECTOR_ARB", ""),
            explorer_url="https://arbiscan.io",
            gas_price_gwei=1
        ),
        ChainID.OPTIMISM_MAIN: ChainConfig(
            chain_id=10,
            name="Optimism",
            rpc_url="https://mainnet.optimism.io",
            pusd_token=os.getenv("PUSD_TOKEN_OP", ""),
            pusd_connector=os.getenv("PUSD_CONNECTOR_OP", ""),
            etf_connector=os.getenv("ETF_CONNECTOR_OP", ""),
            explorer_url="https://optimistic.etherscan.io",
            gas_price_gwei=1
        ),
        ChainID.BASE_MAIN: ChainConfig(
            chain_id=8453,
            name="Base",
            rpc_url="https://mainnet.base.org",
            pusd_token=os.getenv("PUSD_TOKEN_BASE", ""),
            pusd_connector=os.getenv("PUSD_CONNECTOR_BASE", ""),
            etf_connector=os.getenv("ETF_CONNECTOR_BASE", ""),
            explorer_url="https://basescan.org",
            gas_price_gwei=1
        ),
        ChainID.BSC_MAIN: ChainConfig(
            chain_id=56,
            name="BNB Smart Chain",
            rpc_url="https://bsc-dataseed1.binance.org",
            pusd_token=os.getenv("PUSD_TOKEN_BSC", ""),
            pusd_connector=os.getenv("PUSD_CONNECTOR_BSC", ""),
            etf_connector=os.getenv("ETF_CONNECTOR_BSC", ""),
            explorer_url="https://bscscan.com",
            gas_price_gwei=5
        ),
        ChainID.POLYGON_MAIN: ChainConfig(
            chain_id=137,
            name="Polygon",
            rpc_url="https://polygon-rpc.com",
            pusd_token=os.getenv("PUSD_TOKEN_MATIC", ""),
            pusd_connector=os.getenv("PUSD_CONNECTOR_MATIC", ""),
            etf_connector=os.getenv("ETF_CONNECTOR_MATIC", ""),
            explorer_url="https://polygonscan.com",
            gas_price_gwei=30
        ),
        ChainID.GNOSIS_MAIN: ChainConfig(
            chain_id=100,
            name="Gnosis Chain",
            rpc_url="https://rpc.gnosischain.com",
            pusd_token=os.getenv("PUSD_TOKEN_GNOSIS", ""),
            pusd_connector=os.getenv("PUSD_CONNECTOR_GNOSIS", ""),
            etf_connector=os.getenv("ETF_CONNECTOR_GNOSIS", ""),
            explorer_url="https://gnosisscan.io",
            gas_price_gwei=2
        )
    }
  • Dataclass defining the structure for chain configurations used in CHAIN_CONFIGS and accessed by get_chain_info.
    @dataclass
    class ChainConfig:
        """Configuration for a blockchain network"""
        chain_id: int
        name: str
        rpc_url: str
        pusd_token: str
        pusd_connector: str
        etf_connector: str
        explorer_url: str
        gas_price_gwei: int = 20
  • Enum defining supported chain IDs as strings, used as keys in CHAIN_CONFIGS.
    class ChainID(str, Enum):
        ETHEREUM_MAIN = "1"
        OPTIMISM_MAIN = "10"
        BSC_MAIN = "56"
        POLYGON_MAIN = "137"
        BASE_MAIN = "8453"
        ARBITRUM_MAIN = "42161"
        GNOSIS_MAIN = "100"

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/VolumeFi/mcpPADEX'

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