make_invoice
Generate a Bitcoin Lightning invoice with customizable fields such as amount, description, expiry, and metadata, using NWC MCP Server to enable payment functionalities within language models.
Instructions
Create a lightning invoice
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | amount in millisats | |
| description | No | note, memo or description describing the invoice | |
| description_hash | No | hash of a note, memo or description that is too long to fit within the invoice | |
| expiry | No | expiry in seconds | |
| metadata | No | Optional metadata to include with the payment |
Implementation Reference
- src/tools/make_invoice.ts:31-47 (handler)The handler function that executes the tool logic: calls NWC client's makeInvoice with input params and returns the result as a JSON-formatted text content block.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), }, ], }; }
- src/tools/make_invoice.ts:12-30 (schema)Zod-based input schema defining parameters for the make_invoice tool including amount (required), and optional fields like 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(), },
- src/tools/make_invoice.ts:5-49 (registration)The registerMakeInvoiceTool function that registers the 'make_invoice' tool on 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), }, ], }; } ); }
- src/mcp_server.ts:21-21 (registration)Invocation of registerMakeInvoiceTool during MCP server creation to enable the make_invoice tool.registerMakeInvoiceTool(server, client);