Skip to main content
Glama

get_available_trading_tokens

Retrieve available tokens for trading on a specific blockchain within the Paloma DEX ecosystem. Provide a chain ID to get token information for cross-chain trading operations.

Instructions

Get available tokens for trading on a specific chain.

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

Returns:
    JSON string with available trading tokens and their information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_idYes

Implementation Reference

  • Handler function for the 'get_available_trading_tokens' MCP tool. Retrieves trading tokens for a chain using PalomaDEXAPI or fallback mock data, returns JSON with token info.
    @mcp.tool()
    async def get_available_trading_tokens(ctx: Context, chain_id: str) -> str:
        """Get available tokens for trading on a specific chain.
        
        Args:
            chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)
        
        Returns:
            JSON string with available trading tokens and their information.
        """
        try:
            paloma_ctx = ctx.request_context.lifespan_context
            
            if chain_id not in CHAIN_CONFIGS:
                return f"Error: Unsupported chain ID {chain_id}"
            
            config = CHAIN_CONFIGS[chain_id]
            chain_name = get_chain_name_for_api(chain_id)
            
            if not chain_name:
                return f"Error: Chain name mapping not found for chain ID {chain_id}"
            
            # Use our Paloma-based API implementation
            try:
                tokens_data = await paloma_ctx.palomadex_api.get_tokens(chain_id)
                
                result = {
                    "chain": config.name,
                    "chain_id": config.chain_id,
                    "trader_contract": TRADER_ADDRESSES.get(chain_id, "Not configured"),
                    "total_tokens": len(tokens_data),
                    "tradeable_tokens": len([t for t in tokens_data if t.get('is_pair_exist', False)]),
                    "tokens": tokens_data,
                    "data_source": "paloma_dex_api"
                }
                
                return json.dumps(result, indent=2)
            except Exception as api_error:
                logger.warning(f"Paloma API failed: {api_error}, using fallback")
                
                # Fallback: Return common tokens that are likely available for trading
                common_tokens = []
                
                if chain_id == ChainID.ETHEREUM_MAIN:
                    common_tokens = [
                        {"erc20_name": "USD Coin", "erc20_symbol": "USDC", "erc20_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "erc20_decimals": 6, "is_pair_exist": True},
                        {"erc20_name": "Tether USD", "erc20_symbol": "USDT", "erc20_address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", "erc20_decimals": 6, "is_pair_exist": True},
                        {"erc20_name": "Wrapped Ether", "erc20_symbol": "WETH", "erc20_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "erc20_decimals": 18, "is_pair_exist": True}
                    ]
                elif chain_id == ChainID.ARBITRUM_MAIN:
                    common_tokens = [
                        {"erc20_name": "USD Coin", "erc20_symbol": "USDC", "erc20_address": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", "erc20_decimals": 6, "is_pair_exist": True},
                        {"erc20_name": "Tether USD", "erc20_symbol": "USDT", "erc20_address": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", "erc20_decimals": 6, "is_pair_exist": True}
                    ]
                # Add more chains as needed
                
                result = {
                    "chain": config.name,
                    "chain_id": config.chain_id,
                    "trader_contract": TRADER_ADDRESSES.get(chain_id, "Not configured"),
                    "note": "Using fallback token list - Paloma API unavailable",
                    "total_tokens": len(common_tokens),
                    "tradeable_tokens": len(common_tokens),
                    "tokens": common_tokens,
                    "data_source": "fallback"
                }
                
                return json.dumps(result, indent=2)
                    
        except Exception as e:
            logger.error(f"Error getting available tokens: {e}")
            return f"Error getting available tokens: {str(e)}"
  • PalomaDEXAPI.get_tokens helper method called by the handler. Provides mock data for available ERC20 tokens on Ethereum and Arbitrum chains.
    async def get_tokens(self, chain_id: str) -> List[Dict]:
        """Get available tokens for a chain (mock implementation)."""
        # In real implementation, this would query the factory contract
        # For now, return common tokens per chain
        common_tokens = {
            "1": [  # Ethereum
                {"erc20_name": "USD Coin", "erc20_symbol": "USDC", "erc20_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "erc20_decimals": 6, "is_pair_exist": True},
                {"erc20_name": "Tether USD", "erc20_symbol": "USDT", "erc20_address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", "erc20_decimals": 6, "is_pair_exist": True},
                {"erc20_name": "Wrapped Ether", "erc20_symbol": "WETH", "erc20_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "erc20_decimals": 18, "is_pair_exist": True}
            ],
            "42161": [  # Arbitrum
                {"erc20_name": "USD Coin", "erc20_symbol": "USDC", "erc20_address": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", "erc20_decimals": 6, "is_pair_exist": True},
                {"erc20_name": "Tether USD", "erc20_symbol": "USDT", "erc20_address": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", "erc20_decimals": 6, "is_pair_exist": True}
            ]
        }
        
        return common_tokens.get(chain_id, [])
  • Helper function to map chain_id to lowercase chain name used in Paloma DEX API calls.
    def get_chain_name_for_api(chain_id: str) -> Optional[str]:
        """Map chain ID to chain name for Paloma DEX API calls."""
        chain_name_mapping = {
            "1": "ethereum",
            "10": "optimism", 
            "56": "bsc",
            "100": "gnosis",
            "137": "polygon",
            "8453": "base",
            "42161": "arbitrum"
        }
        return chain_name_mapping.get(chain_id)
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it returns JSON with token information. It lacks details on rate limits, authentication needs, error handling, pagination, or whether this is a read-only operation (implied by 'Get' but not explicit). This is inadequate for a tool with potential complexity in a trading environment.

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

Conciseness4/5

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

The description is appropriately sized with a clear purpose statement followed by structured 'Args' and 'Returns' sections. It's front-loaded and efficient, though the 'Returns' section could be slightly more informative given no output schema.

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?

For a single-parameter tool with no annotations and no output schema, the description is minimally adequate. It covers the parameter well but lacks details on return structure, error cases, or behavioral traits, leaving gaps in understanding how to interpret results or handle failures.

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

Parameters4/5

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

The description adds significant value beyond the input schema, which has 0% coverage. It explains 'chain_id' as 'Chain ID' with specific examples (1, 10, 56, etc.), clarifying the parameter's purpose and expected values, which compensates well for the schema's lack of description.

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 verb 'Get' and resource 'available tokens for trading on a specific chain', which is specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_supported_chains' or 'get_etf_tokens', which might have overlapping functionality in a trading context.

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 like 'list_supported_chains' or 'get_etf_tokens'. It mentions a specific chain context but doesn't explain prerequisites, exclusions, or comparative use cases with sibling tools.

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

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