get_historical_prices
Retrieve historical cryptocurrency prices by contract address and timestamp using the MCP server's API. Specify tokens, time, and search range for accurate price data.
Instructions
GET /coins/prices/historical/{timestamp}/{coins}
Get historical prices of tokens by contract address.
Parameters:
timestamp: UNIX timestamp for historical prices
coins: comma-separated tokens in format {chain}:{address}
search_width: time range on either side to find price data (default: '6h')
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coins | Yes | ||
| search_width | No | 6h | |
| timestamp | Yes |
Implementation Reference
- defillama_server.py:622-639 (handler)The handler function for the 'get_historical_prices' tool. It is registered via the @mcp.tool() decorator and implements the logic to fetch historical prices from the DefiLlama API endpoint /coins/prices/historical/{timestamp}/{coins}, using the shared make_request helper.@mcp.tool() async def get_historical_prices( timestamp: int, coins: str, search_width: str = "6h" ) -> str: """GET /coins/prices/historical/{timestamp}/{coins} Get historical prices of tokens by contract address. Parameters: timestamp: UNIX timestamp for historical prices coins: comma-separated tokens in format {chain}:{address} search_width: time range on either side to find price data (default: '6h') """ params = {'searchWidth': search_width} result = await make_request('GET', f'/coins/prices/historical/{timestamp}/{coins}', params) return str(result)