Skip to main content
Glama

get_best_airdrops

Discover high-value cryptocurrency airdrops filtered by criteria like value and deadline. Access ranked airdrop data from DeFiLlama for integration into automation workflows.

Instructions

Obter os melhores airdrops baseado em critérios de valor e facilidade

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNúmero máximo de airdrops para retornar
sortByNoCritério de ordenaçãovalue

Implementation Reference

  • The main handler function that ensures data is loaded, filters active/TBD airdrops, sorts them by the specified criteria (value, deadline, or name), takes the top limit, and returns JSON-formatted response.
    private async getBestAirdrops(args: { limit?: number; sortBy?: string }) { // Garantir que temos dados if (this.cachedAirdrops.length === 0) { await this.getAirdrops({ forceRefresh: true }); } let airdrops = [...this.cachedAirdrops]; const limit = args.limit || 10; // Filtrar apenas airdrops ativos airdrops = airdrops.filter(a => a.status?.toLowerCase().includes('active') || a.status?.toLowerCase().includes('ativo') || a.status?.toLowerCase() === 'tbd' ); // Ordenar baseado no critério switch (args.sortBy) { case 'value': airdrops.sort((a, b) => { const aValue = this.parseValue(a.value); const bValue = this.parseValue(b.value); return bValue - aValue; }); break; case 'deadline': airdrops.sort((a, b) => { const aDate = new Date(a.deadline || '9999-12-31'); const bDate = new Date(b.deadline || '9999-12-31'); return aDate.getTime() - bDate.getTime(); }); break; default: airdrops.sort((a, b) => a.name.localeCompare(b.name)); } const best = airdrops.slice(0, limit); return { content: [ { type: 'text', text: JSON.stringify({ total: best.length, criteria: { limit, sortBy: args.sortBy }, bestAirdrops: best }, null, 2) } ] }; }
  • Input schema defining optional parameters 'limit' (number, default 10) and 'sortBy' (string enum: value/deadline/name, default 'value').
    inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Número máximo de airdrops para retornar', default: 10 }, sortBy: { type: 'string', enum: ['value', 'deadline', 'name'], description: 'Critério de ordenação', default: 'value' } } }
  • src/index.ts:88-107 (registration)
    Tool registration in the listTools response, including name, description, and input schema.
    { name: 'get_best_airdrops', description: 'Obter os melhores airdrops baseado em critérios de valor e facilidade', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Número máximo de airdrops para retornar', default: 10 }, sortBy: { type: 'string', enum: ['value', 'deadline', 'name'], description: 'Critério de ordenação', default: 'value' } } } },
  • src/index.ts:131-132 (registration)
    Dispatcher case in CallToolRequestSchema handler that routes calls to the getBestAirdrops method.
    case 'get_best_airdrops': return await this.getBestAirdrops(args as any);
  • Helper function to parse airdrop value strings into numbers, handling currency symbols, spaces, and multipliers (K, M, B). Used in sorting by value.
    private parseValue(value?: string): number { if (!value) return 0; // Remover símbolos e converter para número const cleaned = value.replace(/[$,\s]/g, ''); const num = parseFloat(cleaned); if (isNaN(num)) return 0; // Detectar multiplicadores (K, M, B) if (value.toLowerCase().includes('k')) return num * 1000; if (value.toLowerCase().includes('m')) return num * 1000000; if (value.toLowerCase().includes('b')) return num * 1000000000; return num; }

Other Tools

Related Tools

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/zarelli1/mcp-defillama-airdrops'

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