Skip to main content
Glama

HiveAuth MCP Server

by AlyssonM
test-batch-operations.js6.89 kB
#!/usr/bin/env node /** * Test script to verify batch operations in MCP server */ import { spawn } from 'child_process'; import path from 'path'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); async function testBatchOperations() { console.log('🔄 Testing Batch Operations in MCP Server...\n'); const serverProcess = spawn('node', ['dist/index.js'], { cwd: __dirname, stdio: ['pipe', 'pipe', 'pipe'] }); let responseData = ''; serverProcess.stdout.on('data', (data) => { responseData += data.toString(); }); function sendMCPMessage(message) { return new Promise((resolve) => { const messageStr = JSON.stringify(message) + '\n'; serverProcess.stdin.write(messageStr); setTimeout(() => { try { const lines = responseData.trim().split('\n').filter(line => line.trim()); const responses = lines.map(line => { try { return JSON.parse(line); } catch (e) { return null; } }).filter(r => r !== null); resolve(responses); } catch (error) { resolve([]); } }, 2000); // Longer timeout for batch operations }); } try { // Initialize server console.log('📋 Test 1: Initialize MCP Server'); await sendMCPMessage({ jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'batch-test-client', version: '1.0.0' } } }); console.log('✅ Server initialized\n'); // Test batch issue credentials console.log('📦 Test 2: Batch Issue Credentials'); responseData = ''; const batchIssueResponse = await sendMCPMessage({ jsonrpc: '2.0', id: 2, method: 'tools/call', params: { name: 'batch_issue_credentials', arguments: { credentials: [ { credentialSubject: { id: 'did:example:student123', name: 'Alice Smith', degree: 'Bachelor of Science', field: 'Computer Science' }, type: ['VerifiableCredential', 'EducationCredential'], vcVersion: '2.0' }, { credentialSubject: { id: 'did:example:student456', name: 'Bob Johnson', degree: 'Master of Arts', field: 'Mathematics' }, type: ['VerifiableCredential', 'EducationCredential'], vcVersion: '1.1' }, { credentialSubject: { id: 'did:example:employee789', name: 'Carol Williams', position: 'Senior Developer', department: 'Engineering' }, type: ['VerifiableCredential', 'EmploymentCredential'] } ], parallel: true } } }); if (batchIssueResponse[0]?.result && !batchIssueResponse[0].result.isError) { console.log('✅ Batch credential issuance completed'); const resultText = batchIssueResponse[0].result.content[0].text; console.log('📊 Results Summary:'); console.log(resultText.split('\\n').slice(0, 10).join('\\n')); } else { console.log('❌ Batch credential issuance failed'); if (batchIssueResponse[0]?.result?.isError) { console.log('Error:', batchIssueResponse[0].result.content[0].text); } } console.log(); // Test batch verify with mock credentials console.log('🔍 Test 3: Batch Verify Credentials'); responseData = ''; const batchVerifyResponse = await sendMCPMessage({ jsonrpc: '2.0', id: 3, method: 'tools/call', params: { name: 'batch_verify_credentials', arguments: { credentials: [ { "@context": ["https://www.w3.org/2018/credentials/v1"], "id": "http://example.edu/credentials/3732", "type": ["VerifiableCredential", "EducationCredential"], "issuer": "did:key:z6MkrHKzgsxrUBLb5gLp3iqFjKM3X5kE", "issuanceDate": "2023-01-01T00:00:00Z", "credentialSubject": { "id": "did:example:student123", "name": "Alice Smith", "degree": "Bachelor of Science" }, "proof": { "type": "Ed25519Signature2020", "created": "2023-01-01T00:00:00Z", "verificationMethod": "did:key:z6MkrHKzgsxrUBLb5gLp3iqFjKM3X5kE#key-1", "proofPurpose": "assertionMethod", "proofValue": "mock-signature-value" } }, { "@context": ["https://www.w3.org/2018/credentials/v1"], "id": "http://example.com/credentials/9876", "type": ["VerifiableCredential", "EmploymentCredential"], "issuer": "did:key:z6MkrHKzgsxrUBLb5gLp3iqFjKM3X5kE", "issuanceDate": "2023-06-01T00:00:00Z", "credentialSubject": { "id": "did:example:employee789", "name": "Carol Williams", "position": "Senior Developer" }, "proof": { "type": "Ed25519Signature2020", "created": "2023-06-01T00:00:00Z", "verificationMethod": "did:key:z6MkrHKzgsxrUBLb5gLp3iqFjKM3X5kE#key-1", "proofPurpose": "assertionMethod", "proofValue": "mock-signature-value-2" } } ], parallel: true, stopOnFirstError: false } } }); if (batchVerifyResponse[0]?.result) { console.log('✅ Batch credential verification completed'); const resultText = batchVerifyResponse[0].result.content[0].text; console.log('📊 Verification Summary:'); console.log(resultText.split('\\n').slice(0, 12).join('\\n')); } else { console.log('❌ Batch credential verification failed'); } console.log('\\n🎉 Batch operations testing completed!'); console.log('\\n📊 **Batch Features Tested:**'); console.log('- ✅ Parallel credential issuance'); console.log('- ✅ Batch credential verification'); console.log('- ✅ Performance metrics and timing'); console.log('- ✅ Detailed error reporting per credential'); console.log('- ✅ Comprehensive result summaries'); console.log('- ✅ Support for mixed VC versions (1.1 and 2.0)'); } catch (error) { console.error('❌ Test failed:', error); } finally { serverProcess.kill(); } } testBatchOperations().catch(console.error);

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/AlyssonM/hiveauth-mcp'

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