Skip to main content
Glama

pay_invoice

Process a Bitcoin Lightning invoice payment via the NWC MCP Server, enabling fast and secure transactions directly within supported platforms.

Instructions

Pay a lightning invoice

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountNoOptional amount in millisats to pay a zero-amount invoice
invoiceYesThe lightning invoice to pay
metadataNoOptional metadata to include with the payment

Implementation Reference

  • The handler function that executes the pay_invoice tool logic: calls client.payInvoice with invoice, optional amount and metadata, then returns the result as formatted JSON text content.
    async (params) => { const result = await client.payInvoice({ invoice: params.invoice, amount: params.amount || undefined, metadata: params.metadata || undefined, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } );
  • Zod input schema for pay_invoice tool parameters: invoice (required string), amount (optional number in millisats), metadata (optional passthrough object).
    { invoice: z.string().describe("The lightning invoice to pay"), amount: z .number() .describe("Optional amount in millisats to pay a zero-amount invoice") .nullish(), metadata: z .object({}) .passthrough() .describe("Optional metadata to include with the payment") .nullish(), },
  • The registerPayInvoiceTool function that registers the pay_invoice tool on the MCP server via server.tool(), including name, description, input schema, and handler.
    export function registerPayInvoiceTool( server: McpServer, client: nwc.NWCClient ) { server.tool( "pay_invoice", "Pay a lightning invoice", { invoice: z.string().describe("The lightning invoice to pay"), amount: z .number() .describe("Optional amount in millisats to pay a zero-amount invoice") .nullish(), metadata: z .object({}) .passthrough() .describe("Optional metadata to include with the payment") .nullish(), }, async (params) => { const result = await client.payInvoice({ invoice: params.invoice, amount: params.amount || undefined, metadata: params.metadata || undefined, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } ); }
  • Top-level call to registerPayInvoiceTool during MCP server initialization.
    registerPayInvoiceTool(server, client);

Other Tools

Related 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