Skip to main content
Glama
test-msp-accounts.ts4.18 kB
#!/usr/bin/env node import dotenv from 'dotenv'; import { UmbrellaAuth } from './auth.js'; import { UmbrellaApiClient } from './api-client.js'; import { getTestCredentialSets } from './auth-helper.js'; dotenv.config(); async function testMSPAccountsEndpoint() { console.log('🧪 TESTING MSP ACCOUNTS ENDPOINT'); console.log('==============================='); const baseURL = process.env.UMBRELLA_API_BASE_URL || 'https://api.umbrellacost.io/api/v1'; const credentialSets = getTestCredentialSets(); if (!credentialSets || credentialSets.length === 0) { console.error('❌ No test credentials available'); return; } // Use the MSP account (first credential set) const mspCreds = credentialSets[0]; console.log(`\n🔍 Testing MSP Account: ${mspCreds.username}`); console.log('='.repeat(50)); const auth = new UmbrellaAuth(baseURL); const apiClient = new UmbrellaApiClient(baseURL); try { // Authenticate with MSP account console.log('🔐 Authenticating MSP account...'); await auth.authenticate(mspCreds); apiClient.setAuthToken(auth.getAuthHeaders()); console.log('✅ MSP authentication successful'); // Test the working endpoint with different parameters console.log('\n🔍 Testing /user-management/accounts endpoint'); console.log('-'.repeat(45)); const response = await apiClient.makeRequest('/user-management/accounts'); if (response.success && response.data) { const accounts = response.data; console.log(`✅ SUCCESS: Found ${accounts.length} accounts/customers`); console.log('\n📊 Account/Customer Details:'); accounts.forEach((account: any, index: number) => { console.log(`\n ${index + 1}. Customer Account:`); console.log(` Account Key: ${account.accountKey || 'N/A'}`); console.log(` Account ID: ${account.accountId || 'N/A'}`); console.log(` Account Name: ${account.accountName || 'N/A'}`); console.log(` Cloud Type ID: ${account.cloudTypeId || 'N/A'}`); console.log(` Standard Provider: ${account.isStandardProvider ? 'Yes' : 'No'}`); console.log(` All Keys: ${Object.keys(account).join(', ')}`); }); // Test some natural language patterns console.log('\n🗣️ TESTING NATURAL LANGUAGE RESPONSES:'); console.log('-'.repeat(45)); // Test "List all customers" console.log('\n👤 USER: "List all my customers"'); console.log('🤖 ASSISTANT: '); let output = `👥 **MSP Customer Portfolio:**\n\nI found ${accounts.length} customers in your MSP account:\n\n`; accounts.forEach((account: any, index: number) => { const name = account.accountName || account.accountKey || `Customer ${index + 1}`; const id = account.accountId || account.accountKey || 'Unknown'; output += `${index + 1}. ${name} (ID: ${id})\n`; }); output += `\n**MSP Overview:**\n- Total Customers: ${accounts.length}\n- Account Type: MSP (Managed Service Provider)\n- Customer Management: Full access\n\nWould you like detailed information about a specific customer?`; console.log(output); // Test "Show me top customers" console.log('\n👤 USER: "Show me my top customers by usage"'); console.log('🤖 ASSISTANT: '); output = `👥 **Top MSP Customers:**\n\nAs an MSP, you manage ${accounts.length} customer accounts. Here are your key customers:\n\n`; accounts.slice(0, 5).forEach((account: any, index: number) => { const name = account.accountName || account.accountKey || `Customer ${index + 1}`; output += `${index + 1}. ${name}\n`; }); output += `\n**MSP Capabilities:**\n- Customer cost analysis and reporting\n- Multi-tenant billing and rebilling\n- Customer-specific recommendations\n- Consolidated cost management\n\nWould you like to analyze costs for a specific customer?`; console.log(output); } else { console.log(`❌ FAILED: ${response.error}`); } } catch (error: any) { console.error(`❌ Error: ${error.message}`); } } testMSPAccountsEndpoint().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