"""
Retrieve list of blockchain networks supported by Odos.
"""
import json
from mcp import types
from ...helpers import make_odos_request
from ...mcp import mcp
@mcp.tool(
name="get_supported_chains", description="Get all Chain IDs supported by Odos"
)
async def get_supported_chains() -> list[types.TextContent]:
"""
Gets all supported blockchain networks from Odos API.
"""
try:
response_data = await make_odos_request("/info/chains", method="GET")
output = {
"message": "Successfully fetched supported chains.",
"chains": response_data.get("chains", []),
"chainCount": len(response_data.get("chains", [])),
}
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_chains: {str(e)}"
)
]
except Exception as e: # pylint: disable=broad-except
return [
types.TextContent(
type="text",
text=f"❌ Unexpected Error in get_supported_chains: {str(e)}",
)
]