Skip to main content
Glama

Nostr MCP Server

by AustinKelsay
import { jest } from '@jest/globals'; // Define a simple ZapReceipt type for testing type ZapReceipt = { id: string; pubkey?: string; created_at: number; kind?: number; tags?: string[][]; content?: string; sig?: string; }; // Define result type for prepareAnonymousZap type ZapResult = { success: boolean; invoice: string; targetData: { type: string; }; comment: string; }; // Mock the processZapReceipt function const processZapReceipt = (receipt: ZapReceipt, targetPubkey: string) => { const targetTag = receipt.tags?.find(tag => tag[0] === 'p' && tag[1] === targetPubkey); const direction = targetTag ? 'received' : 'sent'; const amountTag = receipt.tags?.find(tag => tag[0] === 'amount'); const amountSats = amountTag ? parseInt(amountTag[1]) / 1000 : 0; // Convert millisats to sats return { id: receipt.id, direction, amountSats, created_at: receipt.created_at, targetPubkey }; }; // Simple prepareAnonymousZap function for testing const prepareAnonymousZap = (target: string, amount: number, comment: string = ''): Promise<ZapResult> => { return Promise.resolve({ success: true, invoice: `lnbc${amount}`, targetData: { type: target.startsWith('note') ? 'event' : 'profile' }, comment }); }; describe('Zap Tools Functions', () => { const testPubkey = '7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e'; test('processZapReceipt adds targetPubkey to receipt', () => { // Create mock zap receipt const mockZapReceipt: ZapReceipt = { id: 'test-zap-id', created_at: Math.floor(Date.now() / 1000) - 3600, tags: [ ['p', testPubkey], ['amount', '100000'] // 100 sats in millisats ] }; // Process the receipt const result = processZapReceipt(mockZapReceipt, testPubkey); // Check the result expect(result).toHaveProperty('targetPubkey', testPubkey); expect(result.id).toBe(mockZapReceipt.id); expect(result.direction).toBe('received'); expect(result.amountSats).toBe(100); }); test('prepareAnonymousZap returns invoice for profile', async () => { // Test with an npub target const npubTarget = 'npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6'; const amount = 100; const comment = 'Test zap'; // Prepare anonymous zap const result: ZapResult = await prepareAnonymousZap(npubTarget, amount, comment); // Check the result expect(result.success).toBe(true); expect(result.invoice).toBe(`lnbc${amount}`); expect(result.targetData.type).toBe('profile'); expect(result.comment).toBe(comment); }); test('prepareAnonymousZap returns invoice for event', async () => { // Test with a note ID target const noteTarget = 'note1abcdef'; const amount = 200; // Prepare anonymous zap with default empty comment const result: ZapResult = await prepareAnonymousZap(noteTarget, amount); // Check the result expect(result.success).toBe(true); expect(result.invoice).toBe(`lnbc${amount}`); expect(result.targetData.type).toBe('event'); expect(result.comment).toBe(''); }); });

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/AustinKelsay/nostr-mcp-server'

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