pay
Process Lightning Network payments by submitting bolt11 invoices to transfer funds through the MCP Money server.
Instructions
Pay a Lightning invoice
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bolt11 | Yes | Lightning invoice to pay |
Implementation Reference
- wallet.ts:426-438 (handler)The pay method in MCPWallet class that executes the Lightning payment using the underlying NDKCashuWallet's lnPay method. This is the core handler for the 'pay' tool.async pay(bolt11: string): Promise<any> { if (!this.wallet) throw new Error('Wallet not initialized'); try { const result = await this.wallet.lnPay({ pr: bolt11 }); this.saveWallet(); return result; } catch (error) { console.error('Error making payment:', error); throw error; } }
- wallet.ts:561-571 (schema)Defines the input schema, description, and name for the 'pay' tool, returned in the ListTools response for MCP tool discovery.{ name: 'pay', description: 'Pay a Lightning invoice', inputSchema: { type: 'object', properties: { bolt11: { type: 'string', description: 'Lightning invoice to pay' } }, required: ['bolt11'] } },
- wallet.ts:640-661 (registration)Registers and handles the 'pay' tool invocation in the CallToolRequestSchema handler by calling the wallet.pay method and formatting the standardized MCP response.case 'pay': const { bolt11 } = args; if (!bolt11) { throw new Error('bolt11 invoice is required'); } const payResult = await this.wallet.pay(bolt11); if (payResult && payResult.success !== false) { return { content: [{ type: 'text', text: 'Payment successful' }], success: true, bolt11, payResult }; } else { return { content: [{ type: 'text', text: 'Payment failed' }], success: false, bolt11, payResult }; }