Skip to main content
Glama

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
NameRequiredDescriptionDefault
bolt11YesLightning invoice to pay

Implementation Reference

  • 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;
      }
    }
  • 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
        };
      }

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/pablof7z/mcp-money'

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