Skip to main content
Glama
StevenGeller

LDK MCP Server

by StevenGeller

ios_push_notification

Simulate iOS push notifications for Lightning Network payment events to test notification flows and push setup in wallet development.

Instructions

Test payment notification flows and push setup

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notificationTypeNoType of notification to simulatepayment_received
amountSatsNoAmount in satoshis (for payment notifications)

Implementation Reference

  • The main handler function for the 'ios_push_notification' tool. It calls iosService.testPushNotification(), incorporates input arguments, and appends implementation steps and Node.js server integration code.
      execute: async (args: any): Promise<ToolResult> => {
        try {
          const result = await iosService.testPushNotification();
          
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                ...result,
                notificationType: args.notificationType,
                amountSats: args.amountSats,
                implementationSteps: [
                  '1. Request notification permissions on app launch',
                  '2. Register for remote notifications',
                  '3. Handle notification tokens and updates',
                  '4. Process Lightning events in background',
                  '5. Display rich notifications with payment details',
                  '6. Update app badge with pending actions'
                ],
                serverIntegration: `
    // Server-side notification example (Node.js)
    import apn from 'apn';
    
    class LightningNotificationServer {
      private provider: apn.Provider;
      
      constructor() {
        this.provider = new apn.Provider({
          token: {
            key: process.env.APNS_KEY_PATH,
            keyId: process.env.APNS_KEY_ID,
            teamId: process.env.APPLE_TEAM_ID
          },
          production: process.env.NODE_ENV === 'production'
        });
      }
      
      async notifyPaymentReceived(
        deviceToken: string,
        paymentHash: string,
        amountSats: number,
        memo?: string
      ) {
        const notification = new apn.Notification({
          alert: {
            title: "Payment Received",
            subtitle: memo || "Lightning Payment",
            body: \`You received \${amountSats.toLocaleString()} sats\`
          },
          sound: "payment_received.wav",
          badge: 1,
          topic: "com.yourapp.bundle",
          payload: {
            type: "payment_received",
            paymentHash,
            amountSats
          },
          pushType: "alert",
          priority: 10
        });
        
        const result = await this.provider.send(notification, deviceToken);
        
        if (result.failed.length > 0) {
          console.error('Notification failed:', result.failed[0].response);
        }
        
        return result;
      }
    }`.trim()
              }, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                success: false,
                error: error instanceof Error ? error.message : 'Unknown error'
              }, null, 2)
            }],
            isError: true
          };
        }
      }
  • Input schema defining parameters for the tool: notificationType (enum) and amountSats (number).
    inputSchema: {
      type: 'object',
      properties: {
        notificationType: {
          type: 'string',
          enum: ['payment_received', 'channel_opened', 'channel_closed', 'sync_complete'],
          description: 'Type of notification to simulate',
          default: 'payment_received'
        },
        amountSats: {
          type: 'number',
          description: 'Amount in satoshis (for payment notifications)',
          default: 1000
        }
      }
    },
  • src/index.ts:20-20 (registration)
    Import of the pushNotificationTool from its definition file.
    import { pushNotificationTool } from './tools/iosPushNotification.js';
  • src/index.ts:38-62 (registration)
    Registration of pushNotificationTool in the tools array used by MCP server handlers for listTools and callTool requests.
    const tools = [
      generateInvoiceTool,
      payInvoiceTool,
      getChannelStatusTool,
      getNodeInfoTool,
      backupStateTool,
      keychainTestTool,
      backgroundTestTool,
      pushNotificationTool,
      biometricAuthTool,
      createChannelTool,
      closeChannelTool,
      getBalanceTool,
      decodeInvoiceTool,
      listPaymentsTool,
      estimateFeeTool,
      generateMnemonicTool,
      deriveAddressTool,
      getSwiftCodeTool,
      getArchitectureTool,
      testScenarioTool,
      networkGraphTool,
      eventHandlingTool,
      chainSyncTool,
    ];
  • Helper method in IOSService class that provides comprehensive Swift code examples for iOS push notification setup, authorization, payment notifications, and integration with Lightning events. Called by the tool handler.
      async testPushNotification(): Promise<{
        success: boolean;
        message: string;
        swiftCode: string;
      }> {
        const swiftCode = `
    import UserNotifications
    import UIKit
    
    class LightningNotificationService {
        static func requestAuthorization() async -> Bool {
            do {
                let options: UNAuthorizationOptions = [.alert, .badge, .sound]
                let granted = try await UNUserNotificationCenter.current()
                    .requestAuthorization(options: options)
                
                if granted {
                    await MainActor.run {
                        UIApplication.shared.registerForRemoteNotifications()
                    }
                }
                
                return granted
            } catch {
                print("Notification authorization failed: \\(error)")
                return false
            }
        }
        
        static func notifyPaymentReceived(amountMsat: UInt64, description: String?) {
            let content = UNMutableNotificationContent()
            content.title = "Payment Received"
            content.body = "You received \\(amountMsat / 1000) sats"
            if let desc = description {
                content.subtitle = desc
            }
            content.sound = .default
            content.badge = 1
            
            let request = UNNotificationRequest(
                identifier: UUID().uuidString,
                content: content,
                trigger: nil // Immediate delivery
            )
            
            UNUserNotificationCenter.current().add(request) { error in
                if let error = error {
                    print("Failed to deliver notification: \\(error)")
                }
            }
        }
        
        static func handleIncomingPayment(paymentHash: String) {
            // Fetch payment details from LDK
            guard let payment = ldkManager.getPayment(hash: paymentHash) else { return }
            
            // Show notification
            notifyPaymentReceived(
                amountMsat: payment.amountMsat,
                description: payment.description
            )
            
            // Update app badge
            Task { @MainActor in
                UIApplication.shared.applicationIconBadgeNumber += 1
            }
        }
    }`.trim();
    
        return {
          success: true,
          message: 'Push notification test completed',
          swiftCode
        };
      }
Behavior2/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 mentions testing flows and push setup, but doesn't disclose key behavioral traits such as whether this is a read-only or mutative operation, if it requires specific permissions, what side effects occur (e.g., sends actual notifications), or any rate limits. This leaves significant gaps for an agent to understand the tool's behavior.

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

Conciseness4/5

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

The description is a single, efficient sentence that directly states the purpose without unnecessary words. It's front-loaded and appropriately sized for a simple tool, though it could be slightly more informative without losing conciseness.

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 tool's complexity (testing notifications with 2 parameters), no annotations, and no output schema, the description is incomplete. It doesn't cover what the tool returns, error conditions, or behavioral details, making it inadequate for an agent to fully understand and use the tool effectively.

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 fully documents the two parameters (notificationType and amountSats). The description adds no additional meaning beyond the schema, such as explaining how these parameters interact or their impact on the test. Baseline 3 is appropriate since the schema handles 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 tool is for testing payment notification flows and push setup, which gives a general purpose but lacks specificity about what exactly it does (e.g., simulates iOS push notifications). It doesn't clearly distinguish from sibling tools like ios_background_test or ios_biometric_auth, which might also involve iOS testing.

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?

The description implies usage for testing flows and setup, but provides no explicit guidance on when to use this tool versus alternatives (e.g., vs. ios_background_test or ldk_test_scenario). There's no mention of prerequisites, context, or exclusions, leaving the agent with minimal 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/StevenGeller/ldk-mcp'

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