get_mint_balances
Retrieve detailed balance breakdown per mint for AI agents using Nostr and Cashu functionality with MCP Money.
Instructions
Get balance breakdown per mint
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- wallet.ts:252-269 (handler)Core handler function in MCPWallet class that retrieves mint balances from the underlying NDK wallet, converts balances object to a Map<string, number>, computes total (unused), and handles errors by returning empty Map.async getMintBalances(): Promise<Map<string, number>> { if (!this.wallet) throw new Error('Wallet not initialized'); try { const balances = this.wallet.mintBalances; let total = 0; const balanceMap = new Map<string, number>(); for (const [mintUrl, balance] of Object.entries(balances)) { balanceMap.set(mintUrl, balance); total += balance; } return balanceMap; } catch (error) { console.error('Error getting mint balances:', error); return new Map(); } }
- wallet.ts:540-548 (schema)Tool schema definition in the ListTools response, specifying name, description, and empty input schema (no parameters required).{ name: 'get_mint_balances', description: 'Get balance breakdown per mint', inputSchema: { type: 'object', properties: {}, required: [] } },
- wallet.ts:612-621 (handler)MCP server dispatch handler in MCPServer.callTool that invokes wallet.getMintBalances(), formats the Map as a formatted text string with per-mint and total balances, and returns MCP-formatted content.case 'get_mint_balances': const balances = await this.wallet.getMintBalances(); let balanceText = 'Balance per mint:\n'; let total = 0; for (const [mintUrl, balance] of balances) { balanceText += ` ${mintUrl}: ${balance} sats\n`; total += balance; } balanceText += `Total: ${total} sats`; return { content: [{ type: 'text', text: balanceText }] };
- wallet.ts:528-598 (registration)Registration of the tool via the ListToolsRequestSchema handler in MCPServer.setupHandlers(), which statically lists all available tools including get_mint_balances.this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'get_balance', description: 'Get the total wallet balance', inputSchema: { type: 'object', properties: {}, required: [] } }, { name: 'get_mint_balances', description: 'Get balance breakdown per mint', inputSchema: { type: 'object', properties: {}, required: [] } }, { name: 'deposit', description: 'Create a deposit invoice (bolt11) for the specified amount and mint. Returns the invoice immediately for payment. If no mint is specified, all mints will be tried concurrently and the first successful response will be used.', inputSchema: { type: 'object', properties: { amount: { type: 'number', description: 'Amount in satoshis' }, mintUrl: { type: 'string', description: 'Mint URL to deposit to (optional - all mints tried concurrently if not provided)' } }, required: ['amount'] } }, { name: 'pay', description: 'Pay a Lightning invoice', inputSchema: { type: 'object', properties: { bolt11: { type: 'string', description: 'Lightning invoice to pay' } }, required: ['bolt11'] } }, { name: 'zap', description: 'Send a zap to a user', inputSchema: { type: 'object', properties: { recipient: { type: 'string', description: 'User npub or NIP-05 identifier to zap' }, amount: { type: 'number', description: 'Amount in satoshis' }, comment: { type: 'string', description: 'Optional comment' } }, required: ['recipient', 'amount'] } }, { name: 'add_mint', description: 'Add a mint to the wallet', inputSchema: { type: 'object', properties: { mintUrl: { type: 'string', description: 'Mint URL to add' } }, required: ['mintUrl'] } } ] }; });