Skip to main content
Glama
get-actual-msp-customers.cjsβ€’5.99 kB
#!/usr/bin/env node /** * Get the actual MSP customers using the plain-sub-users API */ const { spawn } = require('child_process'); async function getActualMspCustomers() { console.log('πŸ‘₯ FETCHING ACTUAL MSP CUSTOMERS (DIVISIONS)'); console.log('=' .repeat(60)); const server = spawn('node', ['dist/index.js'], { stdio: ['pipe', 'pipe', 'pipe'], env: process.env }); let responses = {}; let responseBuffer = ''; server.stdout.on('data', (data) => { responseBuffer += data.toString(); const lines = responseBuffer.split('\n'); for (let i = 0; i < lines.length - 1; i++) { const line = lines[i].trim(); if (line) { try { const response = JSON.parse(line); if (response.id) { responses[response.id] = response; } } catch (e) { // Not JSON, continue } } } responseBuffer = lines[lines.length - 1]; }); server.stderr.on('data', (data) => { const msg = data.toString(); console.log('πŸ” Debug:', msg.trim()); }); await new Promise(resolve => setTimeout(resolve, 3000)); // Initialize console.log('πŸ“‘ Initializing...'); server.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "0.1.0", capabilities: {}, clientInfo: { name: "msp-customers", version: "1.0.0" } } }) + '\n'); await new Promise(resolve => setTimeout(resolve, 2000)); // Authenticate with AllCloud user console.log('πŸ” Authenticating with AllCloud MSP user...'); server.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: 2, method: "tools/call", params: { name: "authenticate_user", arguments: { username: "david+allcloud@umbrellacost.com", password: "B4*zcI7#F7poEC" } } }) + '\n'); await new Promise(resolve => setTimeout(resolve, 8000)); // Check auth console.log('πŸ” All responses received:', Object.keys(responses).map(id => `${id}: ${responses[id] ? 'exists' : 'missing'}`).join(', ')); console.log('πŸ” Auth response:', JSON.stringify(responses[2], null, 2)); if (responses[2]?.error) { console.log('❌ Authentication failed:', responses[2].error); server.kill(); return; } if (!responses[2]?.result) { console.log('❌ No auth result received'); server.kill(); return; } // Get MSP customers using plain-sub-users API console.log('πŸ‘₯ Calling api___users_plain_sub_users...'); server.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: 3, method: "tools/call", params: { name: "api___users_plain_sub_users", arguments: {} } }) + '\n'); await new Promise(resolve => setTimeout(resolve, 10000)); // Show results console.log('\nπŸ“‹ ACTUAL MSP CUSTOMERS (DIVISIONS):'); console.log('=' .repeat(70)); const customerResponse = responses[3]; if (customerResponse) { if (customerResponse.error) { console.log('❌ Error:', JSON.stringify(customerResponse.error, null, 2)); } else if (customerResponse.result?.content?.[0]?.text) { const responseText = customerResponse.result.content[0].text; console.log(responseText); // Try to extract customer data from the response console.log('\nπŸ” PARSING CUSTOMER DATA:'); // Look for JSON in the response const jsonMatch = responseText.match(/```json\s*([\s\S]*?)\s*```/); if (jsonMatch) { try { const data = JSON.parse(jsonMatch[1]); // The data might have customers in different structures if (data.divisionsIds && Array.isArray(data.divisionsIds)) { console.log(`πŸ“Š Found division structure with ${data.divisionsIds.length} division IDs`); } // Look for accounts array which might contain customer divisions if (data.accounts && Array.isArray(data.accounts)) { console.log(`πŸ“Š Found ${data.accounts.length} accounts`); // Group accounts by division const divisions = new Map(); data.accounts.forEach((account, index) => { const divisionId = account.divisionId; const accountName = account.accountName; const accountKey = account.accountKey; if (divisionId && divisionId !== 0) { if (!divisions.has(divisionId)) { divisions.set(divisionId, []); } divisions.get(divisionId).push({ accountName, accountKey, accountId: account.accountId }); } console.log(` ${index + 1}. "${accountName}" (Key: ${accountKey}, Division: ${divisionId})`); }); if (divisions.size > 0) { console.log(`\n🎯 FOUND ${divisions.size} CUSTOMER DIVISIONS:`); for (const [divisionId, accounts] of divisions.entries()) { console.log(` Division ${divisionId}: ${accounts.length} accounts`); accounts.forEach((acc, i) => { console.log(` ${i + 1}. "${acc.accountName}" β†’ ${acc.accountKey}`); }); } } else { console.log('\n⚠️ No customer divisions found (all accounts in division 0)'); } } } catch (e) { console.log('❌ Failed to parse JSON:', e.message); } } else { console.log('❌ No JSON block found in response'); console.log('Raw response snippet:', responseText.substring(0, 500) + '...'); } } else { console.log('❌ No content in response'); } } else { console.log('❌ No response received'); } server.kill(); console.log('\nβœ… Done'); } getActualMspCustomers().catch(console.error);

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/daviddraiumbrella/invoice-monitoring'

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