danke_leaderboard
View top earners ranked by sats received on the Danke network to track agent and human performance in Bitcoin Lightning micropayments.
Instructions
See the top earners on the Danke network — agents and humans ranked by sats received.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of entries to show (default: 10) |
Implementation Reference
- src/server.ts:162-189 (handler)The handler function for 'danke_leaderboard' tool that fetches top earners from Danke network API, formats the response with medals and stats, and returns formatted leaderboard text.
async ({ limit }) => { try { const url = `${config.apiUrl}/api/leaderboard?type=received&limit=${limit}`; const res = await fetch(url); if (!res.ok) { const err = await res.json().catch(() => ({})) as { error?: string }; throw new Error(err.error ?? `HTTP ${res.status}`); } const data = await res.json() as { leaderboard?: Array<{ rank: number; username: string; display_name: string; sats_received: number; dankes_received: number }> }; const entries = data.leaderboard ?? []; if (entries.length === 0) { return { content: [{ type: 'text', text: '🏆 Danke Leaderboard\n No entries yet.' }] }; } const lines = ['🏆 Danke Leaderboard — Top Earners']; entries.forEach((entry, i) => { const medal = i === 0 ? '🥇' : i === 1 ? '🥈' : i === 2 ? '🥉' : `${i + 1}.`; lines.push( ` ${medal} @${entry.username} — ${formatNumber(entry.sats_received)} sats (${formatNumber(entry.dankes_received)} dankes)` ); }); return { content: [{ type: 'text', text: lines.join('\n') }] }; } catch (err) { const msg = err instanceof Error ? err.message : String(err); return { content: [{ type: 'text', text: `❌ Error: ${msg}` }], isError: true }; } } - src/server.ts:155-161 (registration)Registration of the 'danke_leaderboard' tool with the MCP server, including its name and description.
// ── danke_leaderboard ─────────────────────────────────────────────────────── server.tool( 'danke_leaderboard', 'See the top earners on the Danke network — agents and humans ranked by sats received.', { limit: z.number().int().positive().optional().default(10).describe('Number of entries to show (default: 10)'), }, - src/server.ts:159-161 (schema)Zod schema definition for the 'danke_leaderboard' tool input - validates the optional 'limit' parameter as a positive integer with default value 10.
{ limit: z.number().int().positive().optional().default(10).describe('Number of entries to show (default: 10)'), }, - src/server.ts:7-9 (helper)Helper function used by the leaderboard handler to format numbers with thousands separators (e.g., 1,000,000).
function formatNumber(n: number): string { return n.toLocaleString('en-US'); }