"""
Get fiat currency exchange rates for token price conversion.
"""
import json
from mcp import types
from ...helpers import make_odos_request
from ...mcp import mcp
# class GetCurrenciesArgs(BaseModel):
# """No arguments needed for this endpoint"""
@mcp.tool(
name="get_currencies",
description="Get list of available currencies and exchange rates for token prices",
)
# disable-next-line=unused-argument # using _args makes the library error.
async def get_currencies() -> list[types.TextContent]:
"""
Gets list of available currencies from Odos API.
"""
try:
response_data = await make_odos_request("/pricing/currencies", method="GET")
output = {
"message": "Successfully fetched available currencies.",
"currencies": response_data.get("currencies", []),
}
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_currencies: {str(e)}"
)
]
except (ValueError, KeyError, TypeError) as e:
return [
types.TextContent(
type="text", text=f"❌ Unexpected Error in get_currencies: {str(e)}"
)
]