Skip to main content
Glama
StevenGeller

LDK MCP Server

by StevenGeller

ios_keychain_test

Validate private key storage patterns with iOS Keychain to test encryption and secure data handling for Lightning wallet development.

Instructions

Validate private key storage patterns with iOS Keychain

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyTypeYesType of key to testseed
testValueNoTest value to store (will be encrypted)

Implementation Reference

  • The execute function implementing the core tool logic: generates test value, calls iosService.testKeychain, formats response with success status, Swift code example, and security recommendations.
    execute: async (args: any): Promise<ToolResult> => {
      try {
        const testValue = args.testValue || `test_${args.keyType}_${Date.now()}`;
        const result = await iosService.testKeychain(args.keyType, testValue);
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              success: result.success,
              message: result.message,
              swiftExample: result.swiftCode,
              keyType: args.keyType,
              recommendations: [
                'Use kSecAttrAccessibleWhenUnlockedThisDeviceOnly for maximum security',
                'Enable biometric protection for sensitive operations',
                'Implement secure key deletion on app uninstall',
                'Use unique identifiers for each key type',
                'Consider using Secure Enclave for key generation'
              ]
            }, 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: keyType (required enum: seed/privateKey/channelSecrets) and optional testValue.
    inputSchema: {
      type: 'object',
      properties: {
        keyType: {
          type: 'string',
          enum: ['seed', 'privateKey', 'channelSecrets'],
          description: 'Type of key to test',
          default: 'seed'
        },
        testValue: {
          type: 'string',
          description: 'Test value to store (will be encrypted)'
        }
      },
      required: ['keyType']
    },
  • src/index.ts:18-18 (registration)
    Import of the keychainTestTool from its implementation file.
    import { keychainTestTool } from './tools/iosKeychainTest.js';
  • src/index.ts:44-44 (registration)
    Registration of the tool by inclusion in the central tools array used by the MCP server.
    keychainTestTool,
  • Supporting method in IOSService that simulates keychain operations by returning Swift code examples for secure storage/retrieval using SecItemAdd/Delete/CopyMatching with high security attributes.
      async testKeychain(key: string, value: string): Promise<{
        success: boolean;
        message: string;
        swiftCode: string;
      }> {
        const swiftCode = `
    import Security
    import Foundation
    
    func saveToKeychain(key: String, value: Data) -> Bool {
        let query: [String: Any] = [
            kSecClass as String: kSecClassGenericPassword,
            kSecAttrAccount as String: key,
            kSecValueData as String: value,
            kSecAttrAccessible as String: kSecAttrAccessibleWhenUnlockedThisDeviceOnly
        ]
        
        // Delete any existing item
        SecItemDelete(query as CFDictionary)
        
        // Add new item
        let status = SecItemAdd(query as CFDictionary, nil)
        return status == errSecSuccess
    }
    
    func loadFromKeychain(key: String) -> Data? {
        let query: [String: Any] = [
            kSecClass as String: kSecClassGenericPassword,
            kSecAttrAccount as String: key,
            kSecReturnData as String: true,
            kSecMatchLimit as String: kSecMatchLimitOne
        ]
        
        var result: AnyObject?
        let status = SecItemCopyMatching(query as CFDictionary, &result)
        
        if status == errSecSuccess {
            return result as? Data
        }
        return nil
    }
    
    // Example usage with LDK seed
    let seedKey = "ldk_node_seed"
    let seed = Data(/* 32 bytes of entropy */)
    let saved = saveToKeychain(key: seedKey, value: seed)
    print("Seed saved: \\(saved)")`.trim();
    
        return {
          success: true,
          message: `Keychain test for key '${key}' completed successfully`,
          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 of behavioral disclosure. It mentions that the test value 'will be encrypted', which adds some context about security handling. However, it lacks critical details such as whether this is a read-only test, if it modifies the Keychain, what permissions are required, potential side effects, or how results are returned. For a tool involving iOS Keychain operations, 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.

Conciseness4/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and context. However, it could be slightly more structured by including brief usage hints, but as-is, it earns a high score for conciseness with minimal waste.

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 iOS Keychain operations and the lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects like safety, permissions, or result format, which are crucial for an agent to use this tool correctly. While the schema covers parameters well, the overall context for secure storage validation is insufficient, especially compared to siblings that may have more detailed descriptions.

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 both parameters (keyType with enum and testValue). The description adds no additional meaning beyond the schema, such as explaining what 'Validate private key storage patterns' entails in terms of these parameters or providing examples. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 as 'Validate private key storage patterns with iOS Keychain', which specifies the action (validate), target (storage patterns), and technology context (iOS Keychain). It distinguishes itself from siblings like ios_background_test or ios_biometric_auth by focusing on key storage validation rather than background processes or authentication. However, it doesn't explicitly differentiate from all siblings, such as ldk_backup_state which might involve storage, keeping it from 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. It doesn't mention prerequisites, such as needing iOS Keychain access or specific device conditions, nor does it compare to siblings like ios_biometric_auth for related security tasks. Without any usage context or exclusions, the agent must infer when this tool is appropriate based on the name alone.

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