Skip to main content
Glama
StevenGeller

LDK MCP Server

by StevenGeller

ldk_node_info

Retrieve current node status and connectivity details to monitor Lightning Network performance and troubleshoot connection issues.

Instructions

Get current node status and connectivity information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for 'ldk_node_info' tool. Fetches node information and balance from LightningService, formats it into JSON response including node ID, alias, version, sync status, channels, balance, peers, and provides a SwiftUI example for iOS display.
      execute: async (args: any): Promise<ToolResult> => {
        try {
          const nodeInfo = await lightningService.getNodeInfo();
          const balance = await lightningService.getBalance();
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                success: true,
                nodeInfo: {
                  nodeId: nodeInfo.nodeId,
                  alias: nodeInfo.alias,
                  version: nodeInfo.version,
                  blockHeight: nodeInfo.blockHeight,
                  syncedToChain: nodeInfo.syncedToChain,
                  channels: {
                    total: nodeInfo.numChannels,
                    usable: nodeInfo.numUsableChannels
                  },
                  balance: {
                    totalSats: Math.floor(balance.totalMsat / 1000),
                    spendableSats: Math.floor(balance.spendableMsat / 1000)
                  },
                  peers: nodeInfo.numPeers
                },
                swiftExample: `
    // Swift code to display node info in your iOS app
    import SwiftUI
    import LightningDevKit
    
    struct NodeInfoView: View {
        @State private var nodeInfo: NodeInfo?
        @State private var isLoading = true
        @State private var isSyncing = false
        
        var body: some View {
            ScrollView {
                VStack(spacing: 20) {
                    // Node Identity Card
                    VStack(alignment: .leading, spacing: 12) {
                        HStack {
                            Image(systemName: "bolt.circle.fill")
                                .font(.largeTitle)
                                .foregroundColor(.orange)
                            
                            VStack(alignment: .leading) {
                                Text(nodeInfo?.alias ?? "Lightning Node")
                                    .font(.title2)
                                    .fontWeight(.semibold)
                                
                                Text(nodeInfo?.nodeId.prefix(16) ?? "")
                                    .font(.caption)
                                    .foregroundColor(.secondary)
                                    .monospaced()
                            }
                            
                            Spacer()
                        }
                        
                        Divider()
                        
                        // Sync Status
                        HStack {
                            Label(
                                nodeInfo?.syncedToChain == true ? "Synced" : "Syncing...",
                                systemImage: nodeInfo?.syncedToChain == true ? "checkmark.circle.fill" : "arrow.triangle.2.circlepath"
                            )
                            .foregroundColor(nodeInfo?.syncedToChain == true ? .green : .orange)
                            
                            Spacer()
                            
                            Text("Block \\(nodeInfo?.blockHeight ?? 0)")
                                .font(.caption)
                                .foregroundColor(.secondary)
                        }
                    }
                    .padding()
                    .background(Color(UIColor.secondarySystemBackground))
                    .cornerRadius(12)
                    
                    // Stats Grid
                    LazyVGrid(columns: [
                        GridItem(.flexible()),
                        GridItem(.flexible())
                    ], spacing: 16) {
                        StatCard(
                            title: "Channels",
                            value: "\\(nodeInfo?.numUsableChannels ?? 0)/\\(nodeInfo?.numChannels ?? 0)",
                            icon: "link",
                            color: .blue
                        )
                        
                        StatCard(
                            title: "Peers",
                            value: "\\(nodeInfo?.numPeers ?? 0)",
                            icon: "person.2",
                            color: .green
                        )
                        
                        StatCard(
                            title: "Total Balance",
                            value: "\\(formatSats(nodeInfo?.totalBalanceSats ?? 0))",
                            icon: "bitcoinsign.circle",
                            color: .orange
                        )
                        
                        StatCard(
                            title: "Spendable",
                            value: "\\(formatSats(nodeInfo?.spendableBalanceSats ?? 0))",
                            icon: "paperplane",
                            color: .purple
                        )
                    }
                    
                    // Actions
                    VStack(spacing: 12) {
                        Button(action: syncToTip) {
                            Label("Sync to Chain Tip", systemImage: "arrow.clockwise")
                                .frame(maxWidth: .infinity)
                        }
                        .buttonStyle(.bordered)
                        .disabled(isSyncing)
                        
                        Button(action: openChannel) {
                            Label("Open Channel", systemImage: "plus.circle")
                                .frame(maxWidth: .infinity)
                        }
                        .buttonStyle(.borderedProminent)
                    }
                    .padding(.top)
                }
                .padding()
            }
            .navigationTitle("Node Info")
            .navigationBarTitleDisplayMode(.inline)
            .refreshable {
                await loadNodeInfo()
            }
            .task {
                await loadNodeInfo()
            }
            .overlay {
                if isLoading {
                    ProgressView("Loading node info...")
                        .padding()
                        .background(Color(UIColor.systemBackground))
                        .cornerRadius(10)
                        .shadow(radius: 5)
                }
            }
        }
        
        func loadNodeInfo() async {
            isLoading = true
            defer { isLoading = false }
            
            // Fetch node info from LDK
            let ldkManager = LDKManager.shared
            nodeInfo = await ldkManager.getNodeInfo()
        }
        
        func syncToTip() {
            Task {
                isSyncing = true
                defer { isSyncing = false }
                
                await LDKManager.shared.syncToChainTip()
                await loadNodeInfo()
            }
        }
        
        func openChannel() {
            // Navigate to channel opening view
        }
        
        func formatSats(_ sats: Int64) -> String {
            let formatter = NumberFormatter()
            formatter.numberStyle = .decimal
            formatter.groupingSeparator = ","
            return formatter.string(from: NSNumber(value: sats)) ?? "0"
        }
    }
    
    struct StatCard: View {
        let title: String
        let value: String
        let icon: String
        let color: Color
        
        var body: some View {
            VStack(spacing: 8) {
                HStack {
                    Image(systemName: icon)
                        .foregroundColor(color)
                    Spacer()
                }
                
                VStack(alignment: .leading, spacing: 4) {
                    Text(value)
                        .font(.title3)
                        .fontWeight(.semibold)
                    
                    Text(title)
                        .font(.caption)
                        .foregroundColor(.secondary)
                }
                .frame(maxWidth: .infinity, alignment: .leading)
            }
            .padding()
            .background(Color(UIColor.secondarySystemBackground))
            .cornerRadius(10)
        }
    }`.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 for the ldk_node_info tool, which requires no parameters (empty properties).
    inputSchema: {
      type: 'object',
      properties: {}
    },
  • src/index.ts:13-62 (registration)
    Registration of the ldk_node_info tool: imported from ./tools/getNodeInfo.js and included in the central tools array provided to the MCP server for listTools and callTool handlers.
    import { generateInvoiceTool } from './tools/generateInvoice.js';
    import { payInvoiceTool } from './tools/payInvoice.js';
    import { getChannelStatusTool } from './tools/getChannelStatus.js';
    import { getNodeInfoTool } from './tools/getNodeInfo.js';
    import { backupStateTool } from './tools/backupState.js';
    import { keychainTestTool } from './tools/iosKeychainTest.js';
    import { backgroundTestTool } from './tools/iosBackgroundTest.js';
    import { pushNotificationTool } from './tools/iosPushNotification.js';
    import { biometricAuthTool } from './tools/iosBiometricAuth.js';
    import { createChannelTool } from './tools/createChannel.js';
    import { closeChannelTool } from './tools/closeChannel.js';
    import { getBalanceTool } from './tools/getBalance.js';
    import { decodeInvoiceTool } from './tools/decodeInvoice.js';
    import { listPaymentsTool } from './tools/listPayments.js';
    import { estimateFeeTool } from './tools/estimateFee.js';
    import { generateMnemonicTool } from './tools/generateMnemonic.js';
    import { deriveAddressTool } from './tools/deriveAddress.js';
    import { getSwiftCodeTool } from './tools/getSwiftCode.js';
    import { getArchitectureTool } from './tools/getArchitecture.js';
    import { testScenarioTool } from './tools/testScenario.js';
    import { networkGraphTool } from './tools/networkGraph.js';
    import { eventHandlingTool } from './tools/eventHandling.js';
    import { chainSyncTool } from './tools/chainSync.js';
    
    // Aggregate all tools
    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 LightningService.getNodeInfo() that provides the core node status data used by the tool handler.
    async getNodeInfo(): Promise<NodeInfo> {
      return this.nodeInfo;
    }
  • Helper method in LightningService.getBalance() that computes wallet balances from channel local balances, used in the tool response.
    async getBalance(): Promise<{ totalMsat: number; spendableMsat: number }> {
      let totalMsat = 0;
      let spendableMsat = 0;
    
      for (const channel of this.channels.values()) {
        if (channel.state === ChannelState.Open) {
          totalMsat += channel.localBalanceMsat;
          if (channel.isUsable) {
            // Reserve 1% for fees
            spendableMsat += Math.floor(channel.localBalanceMsat * 0.99);
          }
        }
      }
    
      return { totalMsat, spendableMsat };
    }
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 of behavioral disclosure. It mentions 'Get current node status and connectivity information,' which implies a read-only operation, but it doesn't specify details like whether this requires authentication, what data is returned (e.g., format, fields), or any rate limits. For a tool with zero annotation coverage, this is a significant gap in transparency.

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 that directly states the tool's function without any unnecessary words. It is front-loaded and efficient, making it easy to understand at a glance, which is ideal for conciseness.

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?

Given the tool has 0 parameters, 100% schema coverage, and no output schema, the description is minimally adequate. However, it lacks details on what 'node status and connectivity information' entails (e.g., specific fields or format), which could be important for an AI agent to understand the return value. Without annotations or an output schema, the description should provide more context to be fully complete.

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

Parameters4/5

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

The tool has 0 parameters, and the schema description coverage is 100%, so there's no need for parameter details in the description. The description appropriately focuses on the tool's purpose without redundant parameter information, earning a high score as it efficiently handles the lack of parameters.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('current node status and connectivity information'), making it immediately understandable. However, it doesn't differentiate this tool from potential sibling tools that might also provide node-related information, such as 'ldk_channel_status' or 'ldk_network_graph', which prevents a perfect score.

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 provides no guidance on when to use this tool versus alternatives. With sibling tools like 'ldk_channel_status' and 'ldk_network_graph' that might overlap in providing node or network information, there's no indication of when this tool is preferred or what specific context it serves, leaving usage ambiguous.

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