Skip to main content
Glama

create_invoice

Generate a Lightning Network invoice to request Bitcoin payments, specifying amount and optional memo for transaction tracking.

Instructions

Create a Lightning invoice to receive payment. Use get_invoice_status to check if paid.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amount_satsYesAmount in satoshis to request
memoNoDescription/memo for the invoice

Implementation Reference

  • MCP tool request handler for 'create_invoice' in src/index.ts.
    case 'create_invoice': {
      const parsed = CreateInvoiceSchema.parse(args);
      const result = await session.requireClient().createInvoice(parsed.amount_sats, parsed.memo);
      const invoiceResponse: Record<string, unknown> = {
        success: true,
        message: `Invoice created for ${parsed.amount_sats} sats`,
        bolt11: result.bolt11,
        payment_hash: result.paymentHash,
        expires_at: result.expiresAt,
      };
      if (result.rawResponse?.tip) {
        invoiceResponse.tip = result.rawResponse.tip;
      }
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(invoiceResponse, null, 2),
          },
        ],
      };
    }
  • Implementation of the 'createInvoice' method in the LightningFaucetClient class.
    async createInvoice(
      amountSats: number,
      memo?: string
    ): Promise<{
      bolt11: string;
      paymentHash: string;
      expiresAt: string;
      rawResponse: CreateInvoiceResponse;
    }> {
      const data: Record<string, unknown> = {
        amount_sats: amountSats,
      };
    
      if (memo) {
        data.memo = memo;
      }
    
      const result = await this.request<CreateInvoiceResponse>('create_invoice', data);
    
      const bolt11 = result.bolt11 || result.invoice || result.payment_request;
      if (!bolt11) {
        throw new Error('No invoice returned from API');
      }
    
      return {
        bolt11,
        paymentHash: result.payment_hash || '',
        expiresAt: result.expires_at || '',
        rawResponse: result,
      };
    }
  • Zod input schema for the 'create_invoice' tool.
    const CreateInvoiceSchema = z.object({
      amount_sats: z.number().int().min(1).max(10_000_000).describe('Amount in satoshis to request'),
      memo: z.string().max(640).optional().describe('Description/memo for the invoice'),
    });

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/lightningfaucet/lightning-wallet-mcp'

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