get_closest_block
Find the blockchain block nearest to a specific UNIX timestamp for a given cryptocurrency chain identifier.
Instructions
GET /coins/block/{chain}/{timestamp}
Get the closest block to a timestamp.
Parameters:
chain: chain identifier
timestamp: UNIX timestamp to find closest block for
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain | Yes | ||
| timestamp | Yes |
Implementation Reference
- defillama_server.py:733-744 (handler)The main handler function for the 'get_closest_block' MCP tool. It uses the shared 'make_request' helper to query the DefiLlama API endpoint '/coins/block/{chain}/{timestamp}' and returns the closest block number for the given chain and timestamp as a string.@mcp.tool() async def get_closest_block(chain: str, timestamp: int) -> str: """GET /coins/block/{chain}/{timestamp} Get the closest block to a timestamp. Parameters: chain: chain identifier timestamp: UNIX timestamp to find closest block for """ result = await make_request('GET', f'/coins/block/{chain}/{timestamp}') return str(result)