parse_invoice
Decode BOLT-11 invoices to extract payment details using a Lightning Network-compatible tool, enabling efficient invoice processing and integration with Lightning addresses.
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 asynchronous handler function that instantiates an Invoice object from the bolt11 'pr' parameter and returns its pretty-printed JSON as text content.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)Zod input schema defining the 'invoice' parameter as a string.{ invoice: z.string().describe("the bolt11 invoice"), },
- src/tools/parse_invoice.ts:5-25 (registration)The registerParseInvoiceTool function that registers the 'parse_invoice' tool on the MCP server, specifying name, description, input schema, and handler.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)Call to register the parse_invoice tool during server initialization.registerParseInvoiceTool(this._server);