Skip to main content
Glama

withdraw

Transfer funds from your Lightning wallet to external BOLT11 invoices using operator authentication, enabling secure withdrawals with built-in security cooldown periods.

Instructions

Withdraw funds from operator account to external Lightning invoice. REQUIRES OPERATOR KEY. Subject to security cooldown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
invoiceYesBOLT11 invoice to pay out to

Implementation Reference

  • The `withdraw` method implementation in `LightningFaucetClient` handles sending funds to an external Lightning invoice.
    async withdraw(invoice: string): Promise<{
      amountSats: number;
      routingFeeSats: number;
      platformFeeSats: number;
      totalCost: number;
      paymentHash: string;
      newBalance: number;
      rawResponse: ApiResponse;
    }> {
      const result = await this.request<ApiResponse & {
        amount_sats?: number;
        routing_fee_sats?: number;
        platform_fee_sats?: number;
        total_cost?: number;
        payment_hash?: string;
        new_balance?: number;
      }>('withdraw', { invoice });
    
      const amountSats = result.amount_sats || 0;
      const routingFeeSats = result.routing_fee_sats || 0;
      const platformFeeSats = result.platform_fee_sats || 0;
    
      return {
        amountSats,
        routingFeeSats,
        platformFeeSats,
        totalCost: result.total_cost || (amountSats + routingFeeSats + platformFeeSats),
        paymentHash: result.payment_hash || '',
        newBalance: result.new_balance || 0,
        rawResponse: result,
      };
    }
  • The MCP tool request handler for the 'withdraw' tool.
    case 'withdraw': {
      const parsed = WithdrawSchema.parse(args);
      const result = await session.requireClient().withdraw(parsed.invoice);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              message: 'Withdrawal successful',
              amount_sats: result.amountSats,
              routing_fee_sats: result.routingFeeSats,
              platform_fee_sats: result.platformFeeSats,
              total_cost: result.totalCost,
              payment_hash: result.paymentHash,
              new_balance: result.newBalance,
            }, null, 2),
          },
        ],
      };
    }
  • The Zod validation schema for the 'withdraw' tool.
    const WithdrawSchema = z.object({
      invoice: z.string().regex(/^ln(bc|tb|bcrt)1[a-z0-9]+$/i, 'Invalid BOLT11 invoice format')
        .describe('BOLT11 invoice to pay out to'),
    });
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates critical behavioral traits: the security requirement ('REQUIRES OPERATOR KEY') and operational constraint ('Subject to security cooldown'), which are essential for safe tool invocation.

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 extremely concise and front-loaded with essential information in just two sentences. Every word earns its place, with no redundant or unnecessary content.

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

Completeness3/5

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

For a financial transaction tool with no annotations and no output schema, the description covers the core purpose, security requirements, and constraints adequately. However, it lacks details about return values, error conditions, or the specific nature of the 'security cooldown,' leaving some gaps in 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?

The input schema has 100% description coverage, with the single parameter 'invoice' documented as 'BOLT11 invoice to pay out to.' The description doesn't add any additional parameter semantics beyond what the schema provides, so it meets the baseline for high schema coverage.

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 ('withdraw funds'), target resource ('from operator account'), and destination ('to external Lightning invoice'). It distinguishes itself from sibling tools like 'check_balance' or 'transfer_to_agent' by focusing on external payouts.

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 provides clear context for when to use this tool ('withdraw funds from operator account to external Lightning invoice') and includes a prerequisite ('REQUIRES OPERATOR KEY'). However, it doesn't explicitly state when not to use it or name alternatives like 'transfer_to_agent' for internal transfers.

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