Skip to main content
Glama
bank-hapoalim-exact-analysis.cjs7.23 kB
#!/usr/bin/env node const { spawn } = require('child_process'); class BankHapoalimExactAnalysis { constructor() { this.server = null; this.requestId = 1; } async start() { console.log('🏦 BANK HAPOALIM - FINDING EXACT MATCH WITH UI'); console.log('=============================================='); this.server = spawn('node', ['dist/index.js'], { stdio: ['pipe', 'pipe', 'pipe'] }); await new Promise(resolve => setTimeout(resolve, 3000)); console.log('✅ Server ready\n'); } async sendRequest(method, params = {}) { return new Promise((resolve, reject) => { const request = { jsonrpc: '2.0', id: this.requestId++, method, params }; this.server.stdin.write(JSON.stringify(request) + '\n'); const timeout = setTimeout(() => { reject(new Error(`Timeout: ${method}`)); }, 30000); const handleData = (data) => { clearTimeout(timeout); this.server.stdout.removeListener('data', handleData); try { const lines = data.toString().split('\n').filter(line => line.trim()); for (let i = lines.length - 1; i >= 0; i--) { const line = lines[i]; if (line.trim()) { try { const response = JSON.parse(line); resolve(response); return; } catch (e) { continue; } } } reject(new Error('No valid JSON response found')); } catch (error) { reject(error); } }; this.server.stdout.on('data', handleData); }); } async getCostData() { try { console.log('🔧 Initialize and Authenticate'); await this.sendRequest('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'Bank Hapoalim Exact Analysis', version: '1.0.0' } }); await this.sendRequest('tools/call', { name: 'authenticate_user', arguments: { username: 'david+allcloud@umbrellacost.com', password: 'B4*zcI7#F7poEC' } }); console.log('✅ Authenticated\n'); // UI Truth Data const uiData = [ { month: "2025-01", cost: 2839.380705943422 }, { month: "2025-02", cost: 3382.1896458348833 }, { month: "2025-03", cost: 2684.566823560157 }, { month: "2025-04", cost: 2060.9445014484645 }, { month: "2025-05", cost: 2236.337430109406 }, { month: "2025-06", cost: 2150.8971216148257 }, { month: "2025-07", cost: 2569.8836261986307 }, { month: "2025-08", cost: 2144.2859467385892 } ]; console.log('🔍 UI REQUEST DETAILS:'); console.log('====================='); console.log('- URL: api-front.umbrellacost.io (Frontend API)'); console.log('- costType: ["cost", "discount"]'); console.log('- excludeFilters[chargetype]: ["Tax"]'); console.log('- isPpApplied: true (MSP pricing)'); console.log('- API Key: 57ade50e-c9a8-49f3-8ce7-28d44536a669:16185:1'); console.log(''); // Test different combinations to find exact match const tests = [ { name: "TEST 1: Cost + Discount, Exclude Tax (Current Implementation)", args: { costType: ['cost', 'discount'], excludeFilters: { chargetype: ['Tax'] } } }, { name: "TEST 2: Cost Only, Exclude Tax", args: { costType: ['cost'], excludeFilters: { chargetype: ['Tax'] } } }, { name: "TEST 3: Cost + Discount, Include Tax", args: { costType: ['cost', 'discount'] } }, { name: "TEST 4: Cost Only, Include Tax", args: { costType: ['cost'] } } ]; for (const test of tests) { console.log(`\n💰 ${test.name}`); console.log('='.repeat(test.name.length + 3)); const resp = await this.sendRequest('tools/call', { name: 'api___invoices_caui', arguments: { startDate: '2025-01-01', endDate: '2025-08-31', groupBy: 'none', periodGranLevel: 'month', cloud_context: 'aws', customer_account_key: '16185', ...test.args } }); const content = resp.result?.content?.[0]?.text; if (content) { const jsonMatch = content.match(/```json\n([\s\S]*?)\n```/); if (jsonMatch) { const mcpData = JSON.parse(jsonMatch[1]); // Calculate differences let totalDiff = 0; let maxDiff = 0; mcpData.forEach((item, index) => { const uiAmount = uiData[index]?.cost || 0; const mcpAmount = item.total_cost; const diff = Math.abs(mcpAmount - uiAmount); totalDiff += diff; maxDiff = Math.max(maxDiff, diff); }); const mcpTotal = mcpData.reduce((sum, item) => sum + item.total_cost, 0); const uiTotal = uiData.reduce((sum, item) => sum + item.cost, 0); console.log(`MCP Total: $${mcpTotal.toFixed(2)}`); console.log(`UI Total: $${uiTotal.toFixed(2)}`); console.log(`Difference: $${Math.abs(mcpTotal - uiTotal).toFixed(2)}`); if (Math.abs(mcpTotal - uiTotal) < 1) { console.log('✅ EXACT MATCH FOUND!'); } else if (Math.abs(mcpTotal - uiTotal) < 100) { console.log('🔶 Close match (within $100)'); } else { console.log('❌ Significant difference'); } } } } console.log('\n\n📊 ANALYSIS OF DIFFERENCES:'); console.log('==========================='); console.log('The UI is using the frontend API (api-front.umbrellacost.io)'); console.log('while MCP uses the backend API (api.umbrellacost.io).'); console.log(''); console.log('Possible reasons for mismatch:'); console.log('1. Frontend API may have different calculation logic'); console.log('2. Frontend API may apply filters differently'); console.log('3. isPpApplied flag may work differently between APIs'); console.log('4. Tax exclusion may be calculated at different stages'); console.log('5. Frontend API may show pre-discount amounts differently'); console.log(''); console.log('The UI shows: $20,068.49 total'); console.log('This appears to be: Gross cost excluding tax, before MSP discount'); } catch (error) { console.error('❌ Error:', error.message); } } async cleanup() { if (this.server) { this.server.kill(); } } async run() { try { await this.start(); await this.getCostData(); } finally { await this.cleanup(); console.log('\n🏁 Bank Hapoalim Exact Analysis Complete'); } } } const costQuery = new BankHapoalimExactAnalysis(); costQuery.run();

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