request_invoice
Generate a Lightning Network invoice by specifying recipient address, amount, and optional payment details for Bitcoin transactions.
Instructions
Request an invoice from a lightning address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lightning_address | Yes | the recipient's lightning address | |
| amount | Yes | amount in sats | |
| description | No | ||
| payer_data | No |
Implementation Reference
- src/tools/request_invoice.ts:26-46 (handler)The handler function that executes the tool: creates a LightningAddress from the input, fetches LNURL data, requests an invoice with the given amount, description, and payer data, then returns the invoice as JSON text content.async (params) => { const ln = new LightningAddress(params.lightning_address); // fetch the LNURL data await ln.fetch(); const invoice = await ln.requestInvoice({ satoshi: params.amount, comment: params.description || undefined, payerdata: params.payer_data || undefined, }); return { content: [ { type: "text", text: JSON.stringify(invoice, null, 2), }, ], }; }
- src/tools/request_invoice.ts:9-25 (schema)Zod schema defining the input parameters: lightning_address (string), amount (number in sats), optional description (string), optional payer_data (object).{ lightning_address: z .string() .describe("the recipient's lightning address"), amount: z.number().describe("amount in sats"), description: z .string() .describe("note, memo or description describing the invoice") .nullish(), payer_data: z .object({}) .passthrough() .describe( "metadata to include with the payment such as the payer's name" ) .nullish(), },
- src/tools/request_invoice.ts:5-48 (registration)The registerRequestInvoiceTool function that registers the "request_invoice" tool on the MCP server using server.tool with name, description, input schema, and handler.export function registerRequestInvoiceTool(server: McpServer) { server.tool( "request_invoice", "Request an invoice from a lightning address", { lightning_address: z .string() .describe("the recipient's lightning address"), amount: z.number().describe("amount in sats"), description: z .string() .describe("note, memo or description describing the invoice") .nullish(), payer_data: z .object({}) .passthrough() .describe( "metadata to include with the payment such as the payer's name" ) .nullish(), }, async (params) => { const ln = new LightningAddress(params.lightning_address); // fetch the LNURL data await ln.fetch(); const invoice = await ln.requestInvoice({ satoshi: params.amount, comment: params.description || undefined, payerdata: params.payer_data || undefined, }); return { content: [ { type: "text", text: JSON.stringify(invoice, null, 2), }, ], }; } ); }
- src/index.ts:28-28 (registration)Invocation of the registerRequestInvoiceTool function in the main server constructor to add the tool to the MCP server instance.registerRequestInvoiceTool(this._server);