Skip to main content
Glama
unixlamadev-spec

lightningprox-mcp

check_payment

Verify Lightning invoice payment status and retrieve spend tokens for pay-per-request AI model access. Use after generating an invoice to confirm payment completion.

Instructions

Check if a Lightning invoice has been paid and retrieve the spend token. Poll this after generate_invoice until the payment is confirmed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
charge_idYesCharge ID returned by generate_invoice

Implementation Reference

  • The `checkPayment` function performs the HTTP request to verify the payment and fetch the spend token.
    async function checkPayment(chargeId: string): Promise<any> {
      const res = await fetch(`${LIGHTNINGPROX_URL}/v1/tokens`, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ charge_id: chargeId, duration_hours: 720 }),
      });
      const data = await res.json() as any;
      return data;
    }
  • The tool definition for `check_payment` including its description and input schema.
    {
      name: "check_payment",
      description:
        "Check if a Lightning invoice has been paid and retrieve the spend token. Poll this after generate_invoice until the payment is confirmed.",
      inputSchema: {
        type: "object",
        properties: {
          charge_id: {
            type: "string",
            description: "Charge ID returned by generate_invoice",
          },
        },
        required: ["charge_id"],
      },
    },
  • src/index.ts:294-326 (registration)
    The request handler in the `server.setRequestHandler` loop for `check_payment` that calls the `checkPayment` function and formats the response.
    case "check_payment": {
      const { charge_id } = args as any;
      const data = await checkPayment(charge_id);
    
      if (data.spend_token) {
        return {
          content: [
            {
              type: "text",
              text: [
                `✅ Payment confirmed!`,
                ``,
                `Your spend token:`,
                data.spend_token,
                ``,
                `Expires: ${data.expires_at || "30 days"}`,
                ``,
                `Use this token in the spend_token field of the chat tool.`,
              ].join("\n"),
            },
          ],
        };
      }
    
      return {
        content: [
          {
            type: "text",
            text: `⏳ Payment not yet confirmed for charge: ${charge_id}\n\nTry again in a few seconds after paying the Lightning 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/unixlamadev-spec/lightningprox-mcp'

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