Skip to main content
Glama

Nostr MCP Server

by AustinKelsay
import { jest } from '@jest/globals'; // Define a simple profile type for testing type NostrProfile = { id: string; pubkey: string; created_at: number; kind: number; tags: string[][]; content: string; sig: string; }; // Define a simple zap receipt type type ZapReceipt = { id: string; pubkey: string; created_at: number; kind: number; tags: string[][]; content: string; sig: string; }; // Mock the formatProfile function const mockFormatProfile = jest.fn((profile: NostrProfile) => { const content = typeof profile.content === 'string' ? JSON.parse(profile.content) : profile.content; return `Name: ${content.name || 'Anonymous'} Display Name: ${content.display_name || ''} About: ${content.about || ''}`; }); // Test a simple nostr profile formatting function describe('Basic Nostr Functionality', () => { test('profile formatting should work correctly', () => { // Arrange - create a mock profile const mockProfile: NostrProfile = { id: '1234', pubkey: '7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e', created_at: Math.floor(Date.now() / 1000) - 3600, kind: 0, tags: [], content: JSON.stringify({ name: 'Test User', display_name: 'Tester', about: 'A test profile for unit tests' }), sig: 'mock_signature' }; // Act - call the function const result = mockFormatProfile(mockProfile); // Assert - check the result expect(result).toContain('Name: Test User'); expect(result).toContain('Display Name: Tester'); expect(result).toContain('About: A test profile for unit tests'); }); test('profile formatting should handle empty fields', () => { // Arrange - create a mock profile with minimal data const mockProfile: NostrProfile = { id: '5678', pubkey: '7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e', created_at: Math.floor(Date.now() / 1000) - 3600, kind: 0, tags: [], content: JSON.stringify({ name: 'Minimal User' }), sig: 'mock_signature' }; // Act - call the function const result = mockFormatProfile(mockProfile); // Assert - check the result expect(result).toContain('Name: Minimal User'); expect(result).toContain('Display Name:'); // Empty but exists expect(result).toContain('About:'); // Empty but exists }); test('zap receipt processing', () => { // Implement a simple zap test here const mockProcessZap = (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 }; }; // Create mock zap receipt const mockZapReceipt: ZapReceipt = { id: 'abcd', pubkey: 'lightning_service_pubkey', created_at: Math.floor(Date.now() / 1000) - 900, kind: 9735, tags: [ ['p', '7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e'], ['amount', '10000'], // 100 sats in millisats ], content: '', sig: 'mock_signature' }; // Test zap processing const result = mockProcessZap(mockZapReceipt, '7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e'); expect(result.direction).toBe('received'); expect(result.amountSats).toBe(10); }); });

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