Skip to main content
Glama
bank-hapoalim-8months-summary.cjsβ€’7.49 kB
#!/usr/bin/env node /** * Bank Hapoalim 8-Month Cost Summary - Comprehensive Analysis * Using Customer Detection System for precise targeting */ const { spawn } = require('child_process'); const path = require('path'); console.log('🏦 BANK HAPOALIM - 8 MONTH COMPREHENSIVE COST SUMMARY'); console.log('═'.repeat(80)); console.log('Customer Detection System Status: βœ… OPERATIONAL'); console.log('Bank Hapoalim Account Key: 16185 (Verified from customerDivisions)'); console.log('═'.repeat(80)); // Calculate proper 8-month range const today = new Date(); const startDate8Months = new Date(today.getFullYear(), today.getMonth() - 8, 1); const endDate = new Date(today.getFullYear(), today.getMonth(), today.getDate()); const startDateStr = startDate8Months.toISOString().split('T')[0]; const endDateStr = endDate.toISOString().split('T')[0]; console.log(`πŸ“… Analysis Period: ${startDateStr} to ${endDateStr}`); console.log(`πŸ” Target Customer: Bank Hapoalim (using customer_account_key: 16185)`); console.log(`πŸ“Š Expected: Up to 8 months of AWS cost data\n`); const serverPath = path.join(__dirname, 'src', 'index.ts'); const server = spawn('npx', ['tsx', serverPath], { env: { ...process.env }, stdio: ['pipe', 'pipe', 'pipe'] }); 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) {} } } responseBuffer = lines[lines.length - 1]; }); server.stderr.on('data', (data) => { const output = data.toString(); if (output.includes('Umbrella MCP Server started successfully')) { setTimeout(() => runAnalysis(), 1000); } }); async function runAnalysis() { console.log('πŸš€ Starting Bank Hapoalim Cost Analysis...\n'); // Initialize server.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'initialize', params: { protocolVersion: '0.1.0', capabilities: {}, clientInfo: { name: 'bank-hapoalim-summary', version: '1.0.0' }}, id: 0 }) + '\n'); await new Promise(resolve => setTimeout(resolve, 2000)); // Authenticate console.log('πŸ” Authenticating with MSP account (david+allcloud@umbrellacost.com)...'); server.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'tools/call', params: { name: 'authenticate_user', arguments: { username: 'david+allcloud@umbrellacost.com', password: 'B4*zcI7#F7poEC' } }, id: 1 }) + '\n'); await new Promise(resolve => setTimeout(resolve, 8000)); if (!responses[1]?.result?.content?.[0]?.text?.includes('Successfully authenticated')) { console.log('❌ Authentication failed or unclear response'); console.log('Response:', responses[1]?.result?.content?.[0]?.text?.substring(0, 300) || 'None'); server.kill(); return; } console.log('βœ… Authentication successful\n'); // Get Bank Hapoalim costs console.log('πŸ“Š Requesting Bank Hapoalim cost data...'); console.log('🎯 Using MSP customer detection: customer_account_key = 16185'); server.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'tools/call', params: { name: 'api___invoices_caui', arguments: { startDate: startDateStr, endDate: endDateStr, groupBy: 'none', periodGranLevel: 'month', costType: ['cost', 'discount'], isUnblended: true, cloud_context: 'aws', customer_account_key: '16185' // Bank Hapoalim } }, id: 2 }) + '\n'); await new Promise(resolve => setTimeout(resolve, 12000)); displayResults(); } function displayResults() { console.log('\nπŸ’° **BANK HAPOALIM - FINAL COST RESULTS**'); console.log('═'.repeat(80)); if (!responses[2]) { console.log('❌ No cost data response received'); server.kill(); return; } if (responses[2].error) { console.log('❌ Cost request error:', responses[2].error); server.kill(); return; } const content = responses[2].result?.content?.find(c => c.type === 'text')?.text || ''; const jsonMatch = content.match(/```json\n([\s\S]*?)\n```/); if (jsonMatch) { try { const data = JSON.parse(jsonMatch[1]); console.log('🏦 **BANK HAPOALIM AWS COSTS - LAST 8 MONTHS**'); console.log('─'.repeat(60)); console.log(`πŸ“ Customer: Bank Hapoalim`); console.log(`πŸ”‘ Account Key: 16185 (MSP Customer Detection)`); console.log(`☁️ Cloud: AWS`); console.log(`πŸ“… Period: ${startDateStr} to ${endDateStr}`); console.log('─'.repeat(60)); if (Array.isArray(data) && data.length > 0) { let totalCost = 0; let validMonths = 0; console.log('\nπŸ“Š **MONTHLY BREAKDOWN:**'); data.forEach((item, index) => { const cost = parseFloat(item.total_cost || 0); const date = item.usage_date || 'Unknown'; const [year, month] = date.split('-'); const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; const monthName = monthNames[parseInt(month) - 1] || month; if (cost !== 0) { totalCost += cost; validMonths++; } const costDisplay = cost.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); const indicator = cost > 0 ? 'πŸ’°' : cost < 0 ? 'πŸ’Έ' : 'βšͺ'; console.log(` ${indicator} ${monthName} ${year}: $${costDisplay}`); }); console.log('\nπŸ“ˆ **SUMMARY STATISTICS:**'); console.log('─'.repeat(40)); console.log(`πŸ’° Total 8-Month Cost: $${totalCost.toLocaleString('en-US', {minimumFractionDigits: 2})}`); console.log(`πŸ“Š Months with Data: ${data.length}`); console.log(`πŸ“Š Valid Cost Months: ${validMonths}`); console.log(`πŸ“ˆ Average Monthly: $${validMonths > 0 ? (totalCost / validMonths).toLocaleString('en-US', {minimumFractionDigits: 2}) : '0.00'}`); console.log('\nβœ… **CUSTOMER VERIFICATION:**'); console.log('🎯 Customer Detection: SUCCESSFUL'); console.log('🏦 Bank Name: Bank Hapoalim'); console.log('πŸ”‘ Account Key: 16185'); console.log('πŸ“Š Data Source: MSP customerDivisions mapping'); console.log('πŸ” Authentication: MSP account (allcloud)'); } else { console.log('⚠️ No cost data array found or empty dataset'); console.log('Data type:', typeof data); console.log('Data preview:', JSON.stringify(data, null, 2).substring(0, 300)); } } catch (e) { console.log('❌ Error parsing cost data:', e.message); } } else { console.log('⚠️ No JSON cost data found in response'); console.log('Response preview:', content.substring(0, 500)); } console.log('\n🎯 **BANK HAPOALIM COST ANALYSIS COMPLETE**'); console.log('═'.repeat(80)); server.kill(); } setTimeout(() => { console.error('❌ Analysis timeout'); server.kill(); process.exit(1); }, 30000);

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