Skip to main content
Glama

zap

Send Bitcoin payments to users via Nostr using satoshis. Specify recipient and amount to transfer funds with optional comments.

Instructions

Send a zap to a user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recipientYesUser npub or NIP-05 identifier to zap
amountYesAmount in satoshis
commentNoOptional comment

Implementation Reference

  • Core handler function that implements the zap tool logic using NDKZapper to send zaps to Nostr users.
    async zap(recipient: string, amount: number, comment: string = ''): Promise<any> {
      if (!this.ndk || !this.wallet) throw new Error('NDK or wallet not initialized');
      
      try {
        let user;
        
        // Check if recipient looks like a pubkey (npub or hex)
        if (recipient.startsWith('npub') || (recipient.length === 64 && /^[0-9a-f]+$/i.test(recipient))) {
          // Direct pubkey - use as is
          user = this.ndk.getUser({ npub: recipient.startsWith('npub') ? recipient : nip19.npubEncode(recipient) });
        } else {
          // Assume it's a NIP-05 identifier and try to resolve it
          try {
            user = await this.ndk.getUserFromNip05(recipient);
            if (!user) {
              throw new Error(`Could not resolve NIP-05 identifier: ${recipient}`);
            }
          } catch (nip05Error) {
            throw new Error(`Failed to resolve NIP-05 identifier "${recipient}": ${nip05Error instanceof Error ? nip05Error.message : 'Unknown error'}`);
          }
        }
        
        // Use NDK's built-in zapping with the configured wallet
        const zapper = new NDKZapper(user, amount * 1000, "msat", {
          ndk: this.ndk,
          comment: comment
        });
        
        const zapResult = await zapper.zap();
        
        this.saveWallet();
        return zapResult;
      } catch (error) {
        console.error('Error sending zap:', error);
        throw error;
      }
    }
  • wallet.ts:572-584 (registration)
    Registration of the 'zap' tool in the MCP listTools handler, defining name, description, and input schema.
    {
      name: 'zap',
      description: 'Send a zap to a user',
      inputSchema: {
        type: 'object',
        properties: {
          recipient: { type: 'string', description: 'User npub or NIP-05 identifier to zap' },
          amount: { type: 'number', description: 'Amount in satoshis' },
          comment: { type: 'string', description: 'Optional comment' }
        },
        required: ['recipient', 'amount']
      }
    },
  • MCP callTool request handler case for 'zap' that validates arguments and calls the wallet.zap method.
    case 'zap':
      const { recipient, amount: zapAmount, comment = '' } = args;
      if (!recipient || !zapAmount) {
        throw new Error('recipient and amount are required');
      }
      const zapResult = await this.wallet.zap(recipient, zapAmount, comment);
      
      if (zapResult && zapResult.success !== false) {
        return { 
          content: [{ type: 'text', text: `Successfully zapped ${zapAmount} sats to ${recipient}` }],
          success: true,
          recipient,
          amount: zapAmount,
          comment,
          zapResult
        };
      } else {
        return { 
          content: [{ type: 'text', text: `Failed to zap ${zapAmount} sats to ${recipient}` }],
          success: false,
          recipient,
          amount: zapAmount,
          comment,
          zapResult
        };
      }
Behavior2/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 mentions sending a zap but doesn't specify whether this is a payment operation, what permissions or authentication are required, if it's destructive (likely yes, as it sends funds), rate limits, or what happens on success/failure. This leaves critical behavioral traits unclear.

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, clear sentence with zero wasted words. It's appropriately sized and front-loaded, efficiently stating the core action without unnecessary elaboration.

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

Completeness2/5

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

Given the complexity of a payment tool with no annotations and no output schema, the description is incomplete. It doesn't explain what a zap entails (e.g., Lightning network transaction), return values, error conditions, or dependencies on other tools like 'get_balance' or 'deposit', leaving significant gaps for an AI agent.

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 all parameters (recipient, amount, comment). The description adds no additional meaning beyond what the schema provides, such as explaining what a 'npub' or 'NIP-05 identifier' is or providing context for the amount. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose3/5

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

The description states the action ('send a zap') and target ('to a user'), which provides a basic purpose. However, it doesn't explain what a 'zap' is in this context (likely a Bitcoin Lightning payment given the satoshi amount parameter), nor does it differentiate from sibling tools like 'pay' or 'deposit', leaving the purpose somewhat vague.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'pay' or 'deposit'. The description lacks context about prerequisites (e.g., needing a balance or mint setup), exclusions, or typical use cases, offering minimal usage direction.

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/pablof7z/mcp-money'

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