get_asset_price
Retrieve real-time asset prices from Aave's oracle to assess collateral values and monitor liquidation risks in DeFi positions.
Instructions
Get current price for a specific asset from Aave oracle.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assetAddress | Yes | Token contract address |
Implementation Reference
- src/index.ts:341-374 (handler)MCP server handler for the 'get_asset_price' tool. Validates the assetAddress input, calls AaveClient.getAssetPrice, and returns the price in USD format.case 'get_asset_price': { const assetAddress = args?.assetAddress as string; if (!assetAddress || typeof assetAddress !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'assetAddress parameter is required and must be a string' ); } if (!aaveClient.isValidAddress(assetAddress)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid Ethereum address format' ); } const price = await aaveClient.getAssetPrice(assetAddress); return { content: [ { type: 'text', text: JSON.stringify( { assetAddress, priceUSD: price, }, null, 2 ), }, ], }; }
- src/index.ts:106-119 (registration)Registration of the 'get_asset_price' tool in the MCP listTools handler, including name, description, and input schema.name: 'get_asset_price', description: 'Get current price for a specific asset from Aave oracle.', inputSchema: { type: 'object', properties: { assetAddress: { type: 'string', description: 'Token contract address', }, }, required: ['assetAddress'], }, },
- src/aave-client.ts:182-186 (helper)AaveClient helper method that queries the Aave V3 oracle contract for the asset price and formats it (8 decimals to USD string).async getAssetPrice(assetAddress: string): Promise<string> { const price = await this.oracleContract.getAssetPrice(assetAddress); // Oracle returns price with 8 decimals return ethers.formatUnits(price, 8); }
- src/index.ts:109-118 (schema)Input schema definition for the 'get_asset_price' tool, specifying the required assetAddress parameter.inputSchema: { type: 'object', properties: { assetAddress: { type: 'string', description: 'Token contract address', }, }, required: ['assetAddress'], },
- src/constants.ts:32-33 (helper)ABI definition for the Aave oracle getAssetPrice function used in contract interaction.'function getAssetPrice(address asset) external view returns (uint256)', 'function getAssetsPrices(address[] calldata assets) external view returns (uint256[])',