Skip to main content
Glama
get_current_block.py1.7 kB
""" Retrieve current block number and blockchain network status. """ 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 GetCurrentBlockArgs(BaseModel): """Arguments for getting current block""" chain_id: Union[str, int] @mcp.tool( name="get_current_block", description=( "Get the current block number for Odos on given chain. " "Use this endpoint to monitor the current block number Odos is basing its quotes off of" ), ) async def get_current_block(args: GetCurrentBlockArgs) -> list[types.TextContent]: """ Gets the current block number that Odos is using for quotes on a specific chain. """ try: chain_id = resolve_chain_id(args.chain_id) # Build URL with path parameters url = f"/info/current-block/{chain_id}" response_data = await make_odos_request(url, method="GET") output = { "message": f"Successfully fetched current block number for chain {chain_id}.", "chainId": chain_id, "blockNumber": response_data.get("blockNumber"), } 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_current_block: {str(e)}" ) ] except Exception as e: # pylint: disable=broad-except return [ types.TextContent( type="text", text=f"❌ Unexpected Error in get_current_block: {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