Skip to main content
Glama

make_invoice

Generate Bitcoin Lightning invoices for receiving payments, specifying amount, expiry time, and payment description.

Instructions

Create a lightning invoice

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesamount in millisats
expiryNoexpiry in seconds
descriptionNonote, memo or description describing the invoice
description_hashNohash of a note, memo or description that is too long to fit within the invoice
metadataNoOptional metadata to include with the payment

Implementation Reference

  • The handler function that creates a Lightning invoice using the NWC client and returns the result as formatted text content.
    async (params) => {
      const result = await client.makeInvoice({
        amount: params.amount,
        description: params.description || undefined,
        description_hash: params.description_hash || undefined,
        expiry: params.expiry || undefined,
        metadata: params.metadata || undefined,
      });
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Zod schema defining the input parameters for the make_invoice tool, including amount, expiry, description, etc.
    {
      amount: z.number().describe("amount in millisats"),
      expiry: z.number().describe("expiry in seconds").nullish(),
      description: z
        .string()
        .describe("note, memo or description describing the invoice")
        .nullish(),
      description_hash: z
        .string()
        .describe(
          "hash of a note, memo or description that is too long to fit within the invoice"
        )
        .nullish(),
      metadata: z
        .object({})
        .passthrough()
        .describe("Optional metadata to include with the payment")
        .nullish(),
    },
  • The registerMakeInvoiceTool function that registers the make_invoice tool with the MCP server, including name, description, schema, and handler.
    export function registerMakeInvoiceTool(
      server: McpServer,
      client: nwc.NWCClient
    ) {
      server.tool(
        "make_invoice",
        "Create a lightning invoice",
        {
          amount: z.number().describe("amount in millisats"),
          expiry: z.number().describe("expiry in seconds").nullish(),
          description: z
            .string()
            .describe("note, memo or description describing the invoice")
            .nullish(),
          description_hash: z
            .string()
            .describe(
              "hash of a note, memo or description that is too long to fit within the invoice"
            )
            .nullish(),
          metadata: z
            .object({})
            .passthrough()
            .describe("Optional metadata to include with the payment")
            .nullish(),
        },
        async (params) => {
          const result = await client.makeInvoice({
            amount: params.amount,
            description: params.description || undefined,
            description_hash: params.description_hash || undefined,
            expiry: params.expiry || undefined,
            metadata: params.metadata || undefined,
          });
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        }
      );
    }
  • Call to registerMakeInvoiceTool during MCP server creation, integrating the make_invoice tool.
    registerMakeInvoiceTool(server, client);

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/getAlby/nwc-mcp-server'

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