get_current_prices
Retrieve the current prices of crypto tokens by contract address using chain-specific and Coingecko identifiers. Specify a time range to ensure accurate and up-to-date price data.
Instructions
GET /coins/prices/current/{coins}
Get current prices of tokens by contract address.
Parameters:
coins: comma-separated tokens in format {chain}:{address} (e.g., 'ethereum:0xdF574c24545E5FfEcb9a659c229253D4111d87e1,coingecko:ethereum')
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 |
Implementation Reference
- defillama_server.py:605-620 (handler)The main handler implementation for the 'get_current_prices' MCP tool. It is registered via the @mcp.tool() decorator and handles fetching current token prices from the DefiLlama API by making an HTTP request to the /coins/prices/current endpoint. Includes input schema via type hints and docstring.@mcp.tool() async def get_current_prices( coins: str, search_width: str = "6h" ) -> str: """GET /coins/prices/current/{coins} Get current prices of tokens by contract address. Parameters: coins: comma-separated tokens in format {chain}:{address} (e.g., 'ethereum:0xdF574c24545E5FfEcb9a659c229253D4111d87e1,coingecko:ethereum') 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/current/{coins}', params) return str(result)