Skip to main content
Glama

confirm_payment

Finalize Bitcoin Lightning Network payments by entering the 6-character confirmation code from your payment request to complete transactions.

Instructions

Confirm a pending payment using the nonce code from a previous payment request. Call this after a payment tool returns requiresConfirmation=true with a nonce.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nonceYesThe 6-character confirmation code from the payment request

Implementation Reference

  • The main implementation of the `confirm_payment` tool handler. It validates the provided nonce against a budget service and returns the confirmation status.
    async def confirm_payment(
        nonce: str,
        budget_service: "BudgetService | None" = None,
    ) -> str:
        """
        Confirm a pending payment using the 6-character nonce code.
    
        Call this after a payment tool returns requiresConfirmation=true with a nonce.
        The nonce expires after 2 minutes and can only be used once.
    
        Args:
            nonce: The 6-character confirmation code from the payment request
            budget_service: BudgetService for confirmation validation
    
        Returns:
            JSON with confirmation result or error message
        """
        if not nonce or not nonce.strip():
            return json.dumps({
                "success": False,
                "error": "Nonce is required"
            })
    
        if not budget_service:
            return json.dumps({
                "success": False,
                "error": "Budget service not available"
            })
    
        try:
            confirmation = budget_service.validate_confirmation(nonce.strip().upper())
    
            if confirmation is None:
                return json.dumps({
                    "success": False,
                    "error": "Invalid, expired, or already-used confirmation nonce",
                    "message": "The nonce may have expired (2 minute limit) or was already used. "
                               "Request a new confirmation by calling the original payment tool again."
                })
    
            return json.dumps({
                "success": True,
                "confirmed": True,
                "message": f"Payment of ${confirmation.get('amount_usd', 0):.2f} "
                           f"({confirmation.get('amount_sats', 0):,} sats) confirmed",
                "confirmation": {
                    "nonce": confirmation.get("nonce"),
                    "amountSats": confirmation.get("amount_sats"),
                    "amountUsd": round(confirmation.get("amount_usd", 0), 2),
                    "toolName": confirmation.get("tool_name"),
                    "description": confirmation.get("description"),
                }
            }, indent=2)
    
        except AttributeError:
            # validate_confirmation may not exist on all BudgetService versions
            return json.dumps({
                "success": False,
                "error": "Confirmation validation not supported by current budget service version",
                "hint": "Upgrade the MCP server to support payment confirmations."
            })
        except Exception as e:
            logger.exception("Error confirming payment")
            return json.dumps({
                "success": False,
                "error": sanitize_error(str(e))
            })
  • Tool registration in the MCP server. Includes the tool name, description, and input schema.
    Tool(
        name="confirm_payment",
        description=(
            "Confirm a pending payment using the nonce code from a previous payment request. "
            "Call this after a payment tool returns requiresConfirmation=true with a nonce."
        ),
        inputSchema={
            "type": "object",
Behavior3/5

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

No annotations are provided, so the description carries full burden. It implies this is a mutation tool (confirmation changes state), but doesn't disclose behavioral traits like permissions needed, rate limits, or what happens on failure. It adds some context about the trigger condition, but lacks details on outcomes or error handling.

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?

Two sentences with zero waste: the first states purpose and parameter source, the second provides precise usage timing. It's front-loaded with essential information and appropriately sized for a single-parameter tool.

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 complexity (simple confirmation action), 1 parameter with full schema coverage, and no output schema, the description is mostly complete. It covers purpose, usage context, and parameter origin, but lacks details on return values or error behavior that would be helpful for a mutation tool with no annotations.

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%, so the schema already documents the 'nonce' parameter fully. The description adds minimal value beyond the schema by mentioning it's 'from a previous payment request' and '6-character', but these details are already implied or stated in the schema description. Baseline 3 is appropriate when schema does the heavy lifting.

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 ('Confirm a pending payment') and resource ('using the nonce code from a previous payment request'), distinguishing it from siblings like pay_invoice or verify_l402_payment by focusing on confirmation rather than initiation or verification.

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

Usage Guidelines5/5

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

It explicitly states when to use this tool ('Call this after a payment tool returns requiresConfirmation=true with a nonce'), providing clear context and prerequisites without misleading information about alternatives.

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/refined-element/lightning-enable-mcp'

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