#!/usr/bin/env node
// Final comparison - both systems with monthly aggregation
const axios = require('axios');
console.log('🔍 FINAL AWS COST COMPARISON');
console.log('Testing both systems with monthly aggregation');
console.log('═'.repeat(50));
async function testCurrentServer() {
try {
const loginResponse = await axios.post('http://localhost:3000/auth', {
username: 'david+saola@umbrellacost.com',
password: 'Dsamsung1!'
});
const token = loginResponse.data.bearerToken;
const headers = {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
};
const result = await axios.post('http://localhost:3000/mcp', {
jsonrpc: '2.0',
id: 1,
method: 'tools/call',
params: {
name: 'get_costs',
arguments: {
startDate: '2025-08-01',
endDate: '2025-08-31',
cloud_context: 'aws',
periodGranLevel: 'month'
}
}
}, { headers });
const response = result.data.result?.content?.[0]?.text || '';
const jsonMatch = response.match(/\[([\s\S]*?)\]/);
if (jsonMatch) {
const data = JSON.parse('[' + jsonMatch[1] + ']');
let totalCost = 0;
data.forEach(item => totalCost += parseFloat(item.total_cost || 0));
console.log(`💰 Current Server: $${totalCost.toLocaleString()} (${data.length} items)`);
return totalCost;
}
} catch (error) {
console.log(`❌ Current server error: ${error.message}`);
}
return null;
}
async function main() {
const currentCost = await testCurrentServer();
const rc5Expected = 162635.363;
console.log(`💰 RC5 Expected: $${rc5Expected.toLocaleString()}`);
if (currentCost) {
const difference = currentCost - rc5Expected;
console.log(`📊 Difference: $${difference.toLocaleString()}`);
if (Math.abs(difference) < 0.01) {
console.log('✅ SUCCESS! Current server matches RC5!');
} else {
console.log('❌ Current server does NOT match RC5');
console.log(`❌ Still need to fix: $${Math.abs(difference).toLocaleString()} difference`);
}
}
}
main();