Skip to main content
Glama

decode_invoice

Decode BOLT11 Lightning invoices to view payment details like amount, description, expiry, and destination without making a payment.

Instructions

Decode a BOLT11 invoice without paying it. Returns amount, description, expiry, and destination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bolt11YesBOLT11 invoice string to decode

Implementation Reference

  • The actual implementation of decodeInvoice that makes the API request to decode a BOLT11 invoice.
    async decodeInvoice(bolt11: string): Promise<{
      amountSats: number;
      description: string;
      paymentHash: string;
      destination: string;
      expiresAt: string;
      isExpired: boolean;
      createdAt?: string;
      rawResponse: ApiResponse;
    }> {
      const result = await this.request<ApiResponse & {
        amount_sats?: number;
        num_satoshis?: string;
        description?: string;
        payment_hash?: string;
        destination?: string;
        timestamp?: string;
        expiry?: string;
        expires_at?: string;
        is_expired?: boolean;
      }>('decode_invoice', { invoice: bolt11 });
    
      const amountSats = result.amount_sats || parseInt(result.num_satoshis || '0', 10);
      const timestamp = result.timestamp ? parseInt(result.timestamp, 10) : 0;
      const expiry = result.expiry ? parseInt(result.expiry, 10) : 3600;
      const expiresAt = result.expires_at || new Date((timestamp + expiry) * 1000).toISOString();
      const isExpired = result.is_expired ?? (timestamp + expiry < Date.now() / 1000);
    
      return {
        amountSats,
        description: result.description || '',
        paymentHash: result.payment_hash || '',
        destination: result.destination || '',
        expiresAt,
        isExpired,
        createdAt: timestamp ? new Date(timestamp * 1000).toISOString() : undefined,
        rawResponse: result,
      };
    }
  • src/index.ts:1376-1396 (registration)
    The MCP tool handler that invokes decodeInvoice when the 'decode_invoice' tool is called.
    case 'decode_invoice': {
      const parsed = DecodeInvoiceSchema.parse(args);
      const result = await session.requireClient().decodeInvoice(parsed.bolt11);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              amount_sats: result.amountSats,
              description: result.description,
              payment_hash: result.paymentHash,
              destination: result.destination,
              expires_at: result.expiresAt,
              is_expired: result.isExpired,
              created_at: result.createdAt,
            }, null, 2),
          },
        ],
      };
    }
  • Input validation schema for the decode_invoice tool.
    const DecodeInvoiceSchema = z.object({
      bolt11: z.string().regex(/^ln(bc|tb|bcrt)1[a-z0-9]+$/i, 'Invalid BOLT11 invoice format')
        .describe('BOLT11 invoice string to decode'),
    });
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool is read-only and non-destructive ('without paying it'), which is useful. However, it lacks details on error conditions (e.g., invalid invoice format), rate limits, authentication needs, or response format beyond the listed fields, leaving behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose and key behavior ('without paying it'), followed by the return values. Every word contributes meaning, with no wasted text, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one parameter, no output schema, no annotations), the description is mostly complete: it covers purpose, key behavior, and return values. However, it lacks details on error handling or authentication, which could be relevant for a decoding operation, slightly reducing completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'bolt11' well-documented in the schema. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Decode a BOLT11 invoice without paying it') and distinguishes it from sibling tools like 'pay_invoice' or 'get_invoice_status' by emphasizing the non-payment aspect. It identifies the resource (BOLT11 invoice) and the outcome (returns amount, description, expiry, and destination).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states 'without paying it,' which provides clear context for when to use this tool versus alternatives like 'pay_invoice.' However, it does not mention other potential alternatives (e.g., 'get_invoice_status' for checking payment status) or any prerequisites, such as invoice validity requirements.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/lightningfaucet/lightning-wallet-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server