get_historical_prices
Retrieve historical cryptocurrency token prices by contract address and timestamp for analysis and tracking.
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')
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"timestamp": "<timestamp>",
"coins": "<coins>"
},
"name": "get_historical_prices"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timestamp | Yes | ||
| coins | Yes | ||
| search_width | No | 6h |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- defillama_server.py:622-639 (handler)The handler function decorated with @mcp.tool() that implements the get_historical_prices tool. It fetches historical token prices from the DefiLlama API using the provided timestamp, coins, and search width.
@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)