Skip to main content
Glama
compare-msp-vs-direct.tsβ€’4.82 kB
#!/usr/bin/env node import dotenv from 'dotenv'; import { UmbrellaAuth } from './auth.js'; import { UmbrellaApiClient } from './api-client.js'; dotenv.config(); async function compareMspVsDirect() { console.log('πŸ” COMPARING MSP vs DIRECT CUSTOMER COST ACCESS'); console.log('=============================================='); const baseURL = process.env.UMBRELLA_API_BASE_URL || 'https://api.umbrellacost.io/api/v1'; const credentials = [ { type: 'MSP Customer', username: 'elisha@umbrellacost.cloud', password: '6K2UX6DoYSgV%E' }, { type: 'Direct Customer', username: 'elisha@umbrellacost.net', password: 'G37oi57Kp@cNzx' } ]; const now = new Date(); const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1); const startDate = startOfMonth.toISOString().split('T')[0]; const endDate = now.toISOString().split('T')[0]; for (const cred of credentials) { console.log(`\n${'='.repeat(50)}`); console.log(`πŸ” TESTING: ${cred.type} (${cred.username})`); console.log(`${'='.repeat(50)}`); try { // Authenticate const auth = new UmbrellaAuth(baseURL); await auth.authenticate(cred); const apiClient = new UmbrellaApiClient(baseURL); apiClient.setAuthToken(auth.getAuthHeaders()); console.log(`βœ… Authentication successful`); // Get accounts const accountsResponse = await apiClient.makeRequest('/user-management/accounts'); if (!accountsResponse.success) { console.log(`❌ Cannot get accounts: ${accountsResponse.error}`); continue; } const accounts = accountsResponse.data; console.log(`πŸ“Š Found ${accounts.length} accounts`); // Show account structure accounts.slice(0, 2).forEach((account: any, index: number) => { console.log(`${index + 1}. ${account.accountName}`); console.log(` ID: ${account.accountId}, Key: ${account.accountKey}`); }); // Test cost API with different approaches console.log(`\nπŸ’° Testing cost API approaches:`); // Approach 1: Try with numeric account if available const numericAccount = accounts.find((acc: any) => /^\d+$/.test(acc.accountId)); if (numericAccount) { console.log(`\nπŸ”’ Testing with numeric account: ${numericAccount.accountId}`); try { const costResponse = await apiClient.makeRequest('/invoices/caui', { startDate, endDate, accountId: numericAccount.accountId }); if (costResponse.success) { console.log(`βœ… SUCCESS with numeric account!`); console.log(` Data: ${JSON.stringify(costResponse.data).substring(0, 100)}...`); } else { console.log(`❌ Failed: ${costResponse.error}`); } } catch (error: any) { console.log(`❌ Error: ${error.message}`); } } // Approach 2: Try without accountId (maybe gives aggregated?) console.log(`\nπŸ“Š Testing without accountId (aggregated?):`); try { const costResponse = await apiClient.makeRequest('/invoices/caui', { startDate, endDate }); if (costResponse.success) { console.log(`βœ… SUCCESS without accountId!`); console.log(` Data: ${JSON.stringify(costResponse.data).substring(0, 100)}...`); } else { console.log(`❌ Failed: ${costResponse.error}`); } } catch (error: any) { console.log(`❌ Error: ${error.message}`); } // Approach 3: Try with different working endpoints console.log(`\nπŸ”§ Testing alternative endpoints:`); const alternativeEndpoints = [ '/user-management/cost-summary', '/budgets', '/recommendations/waste-detector' ]; for (const endpoint of alternativeEndpoints) { try { const response = await apiClient.makeRequest(endpoint); if (response.success) { console.log(`βœ… ${endpoint} - SUCCESS`); console.log(` Data type: ${typeof response.data}, Items: ${Array.isArray(response.data) ? response.data.length : 'Object'}`); } else { console.log(`❌ ${endpoint} - Failed: ${response.error}`); } } catch (error: any) { console.log(`❌ ${endpoint} - Error: ${error.message}`); } } } catch (error: any) { console.log(`❌ ${cred.type} test failed: ${error.message}`); } } console.log(`\n${'πŸŽ‰'.repeat(20)}`); console.log('COMPARISON COMPLETE'); console.log(`${'πŸŽ‰'.repeat(20)}`); } compareMspVsDirect().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