Skip to main content
Glama
get_supported_tokens.py1.93 kB
""" Retrieve tokens available for trading on specified blockchain. """ import json from typing import Union from mcp import types from pydantic import BaseModel from ...helpers import make_odos_request, resolve_chain_id from ...mcp import mcp class GetSupportedTokensArgs(BaseModel): """Arguments for getting supported tokens""" chain_id: Union[str, int] @mcp.tool( name="get_supported_tokens", description=( "Get all of the supported ERC-20 tokens that Odos uses for swaps." "These tokens have been manually audited to ensure they work with Odos" ), ) async def get_supported_tokens(args: GetSupportedTokensArgs) -> list[types.TextContent]: """ Gets all supported ERC-20 tokens for a specific chain. """ try: chain_id = resolve_chain_id(args.chain_id) # Build URL with path parameters url = f"/info/tokens/{chain_id}" response_data = await make_odos_request(url, method="GET") token_map = response_data.get("tokenMap", {}) output = { "message": f"Successfully fetched supported tokens for chain {chain_id}.", "chainId": chain_id, "tokenMap": token_map, "tokenCount": len(token_map), "note": ( "Custom tokens can also be used with Odos" "but there is no guarantee Odos will find a valid path" ), } return [types.TextContent(type="text", text=json.dumps(output, indent=2))] except ConnectionError as e: return [ types.TextContent( type="text", text=f"❌ API Error in get_supported_tokens: {str(e)}" ) ] except (ValueError, KeyError, TypeError) as e: return [ types.TextContent( type="text", text=f"❌ Unexpected Error in get_supported_tokens: {str(e)}", ) ]

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/odos-xyz/odos-mcp'

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