Skip to main content
Glama
clumsynonono

Aave Liquidation MCP Server

by clumsynonono

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
NameRequiredDescriptionDefault
assetAddressYesToken contract address

Implementation Reference

  • 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'], }, },
  • 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); }
  • 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'], },
  • 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[])',

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/clumsynonono/aave-liquidation-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server