parse_invoice
Extract payment details from BOLT-11 lightning invoices to verify amounts, destinations, and expiration times for Lightning Network transactions.
Instructions
Parse a BOLT-11 lightning invoice
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invoice | Yes | the bolt11 invoice |
Implementation Reference
- src/tools/parse_invoice.ts:12-23 (handler)The async handler function that takes the invoice parameter, parses it using the Invoice class from @getalby/lightning-tools, and returns a structured content response with the JSON-stringified invoice data.async (params) => { const invoice = new Invoice({ pr: params.invoice }); return { content: [ { type: "text", text: JSON.stringify(invoice, null, 2), }, ], }; }
- src/tools/parse_invoice.ts:9-11 (schema)Input schema defined using Zod: requires 'invoice' as a string, described as 'the bolt11 invoice'.{ invoice: z.string().describe("the bolt11 invoice"), },
- src/tools/parse_invoice.ts:5-25 (registration)The registerParseInvoiceTool function registers the parse_invoice tool with the MCP server, specifying name, description, input schema, and handler function.export function registerParseInvoiceTool(server: McpServer) { server.tool( "parse_invoice", "Parse a BOLT-11 lightning invoice", { invoice: z.string().describe("the bolt11 invoice"), }, async (params) => { const invoice = new Invoice({ pr: params.invoice }); return { content: [ { type: "text", text: JSON.stringify(invoice, null, 2), }, ], }; } ); }
- src/index.ts:30-30 (registration)Invocation of registerParseInvoiceTool during the LightningToolsServer constructor to register the tool with the MCP server instance.registerParseInvoiceTool(this._server);