Skip to main content
Glama
unixlamadev-spec

lightningprox-mcp

generate_invoice

Create Bitcoin Lightning invoices to add funds to LightningProx spend tokens for pay-per-request AI model access. Specify satoshi amount to generate BOLT11 payment request.

Instructions

Generate a Bitcoin Lightning invoice to top up a LightningProx spend token. Returns a BOLT11 payment request and charge ID. Pay the invoice with any Lightning wallet.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amount_satsYesAmount in satoshis to top up (e.g. 5000, 25000, 100000)

Implementation Reference

  • The `generateInvoice` function, which performs the actual API call to LightningProx to generate a BOLT11 invoice and charge ID.
    async function generateInvoice(amountSats: number): Promise<any> {
      const res = await fetch(`${LIGHTNINGPROX_URL}/v1/topup`, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ amount_sats: amountSats, duration_hours: 720 }),
      });
      // 402 is expected — it IS the invoice response
      const data = await res.json() as any;
      if (!data.payment_request && !data.charge_id) {
        throw new Error(data.error || `Invoice generation failed: ${res.status}`);
      }
      return data;
    }
  • src/index.ts:76-90 (registration)
    Tool definition for `generate_invoice` within the `tools` array.
    {
      name: "generate_invoice",
      description:
        "Generate a Bitcoin Lightning invoice to top up a LightningProx spend token. Returns a BOLT11 payment request and charge ID. Pay the invoice with any Lightning wallet.",
      inputSchema: {
        type: "object",
        properties: {
          amount_sats: {
            type: "number",
            description: "Amount in satoshis to top up (e.g. 5000, 25000, 100000)",
          },
        },
        required: ["amount_sats"],
      },
    },
  • The `CallToolRequestSchema` handler case for `generate_invoice`, which parses arguments and calls the `generateInvoice` helper function.
    case "generate_invoice": {
      const { amount_sats } = args as any;
      const data = await generateInvoice(amount_sats);
    
      return {
        content: [
          {
            type: "text",
            text: [
              `⚡ Lightning Invoice Generated`,
              ``,
              `Amount: ${data.amount_sats || amount_sats} sats (~$${data.amount_usd || "?"})`,
              ``,
              `Invoice (BOLT11):`,
              data.payment_request,
              ``,
              `Charge ID: ${data.charge_id}`,
              ``,
              `Pay with any Lightning wallet, then use check_payment with the charge_id to get your spend token.`,
              ``,
              `Or pay at: ${LIGHTNINGPROX_URL}/topup`,
            ].join("\n"),
          },
        ],
      };
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

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/unixlamadev-spec/lightningprox-mcp'

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