#!/usr/bin/env node
const { spawn } = require('child_process');
async function getCloudWatchAug4Week() {
console.log('๐ฐ AMAZONCLOUDWATCH AROUND AUG 4TH (7 days)');
console.log('๐
Period: Aug 1-7, 2025 (around known cost day)');
const server = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe'],
env: {
...process.env,
UMBRELLA_API_BASE_URL: 'https://api-front.umbrellacost.io/api/v1'
}
});
const responses = [];
server.stdout.on('data', (data) => {
const lines = data.toString().split('\n').filter(line => line.trim());
for (const line of lines) {
try {
responses.push(JSON.parse(line));
} catch (e) {}
}
});
await new Promise(resolve => setTimeout(resolve, 2000));
server.stdin.write(JSON.stringify({
jsonrpc: "2.0", id: 1, method: "tools/call",
params: {
name: 'authenticate_user',
arguments: { username: 'david+saola@umbrellacost.com', password: 'Dsamsung1!' }
}
}) + '\n');
await new Promise(resolve => setTimeout(resolve, 6000));
// Test shorter range around Aug 4th
server.stdin.write(JSON.stringify({
jsonrpc: "2.0", id: 2, method: "tools/call",
params: {
name: 'api___invoices_caui',
arguments: {
startDate: "2025-08-01",
endDate: "2025-08-07",
groupBy: "none",
periodGranLevel: "day",
costType: ["cost"],
isAmortized: true,
cloud_context: "aws",
accountId: "932213950603",
filters: {
service: "AmazonCloudWatch"
}
}
}
}) + '\n');
console.log('๐ Testing Aug 1-7 for AmazonCloudWatch...');
await new Promise(resolve => setTimeout(resolve, 10000));
const response = responses.find(r => r.id === 2);
if (response?.result?.content?.[0]?.text) {
const text = response.result.content[0].text;
if (text.includes('0 items')) {
console.log('โ Still 0 items for Aug 1-7');
console.log('๐ค This suggests AmazonCloudWatch might be the wrong format for cost queries');
// Try with original "Amazon CloudWatch" for multi-day
console.log('\n๐งช Testing with "Amazon CloudWatch" for multi-day...');
server.stdin.write(JSON.stringify({
jsonrpc: "2.0", id: 3, method: "tools/call",
params: {
name: 'api___invoices_caui',
arguments: {
startDate: "2025-08-01",
endDate: "2025-08-07",
groupBy: "none",
periodGranLevel: "day",
costType: ["cost"],
isAmortized: true,
cloud_context: "aws",
accountId: "932213950603",
filters: {
service: "Amazon CloudWatch"
}
}
}
}) + '\n');
await new Promise(resolve => setTimeout(resolve, 8000));
const response2 = responses.find(r => r.id === 3);
if (response2?.result?.content?.[0]?.text) {
const text2 = response2.result.content[0].text;
if (text2.includes('0 items')) {
console.log('โ "Amazon CloudWatch" also gives 0 items');
} else {
console.log('โ
"Amazon CloudWatch" works for multi-day!');
}
}
} else {
console.log('โ
Got results for Aug 1-7!');
const jsonMatch = text.match(/```json\n([\s\S]*?)\n```/);
if (jsonMatch) {
try {
const data = JSON.parse(jsonMatch[1]);
if (Array.isArray(data) && data.length > 0) {
let totalCost = 0;
console.log('\n๐ฐ AmazonCloudWatch Aug 1-7 Daily Costs:');
data.forEach((day, i) => {
if (day && day.total_cost !== undefined) {
const cost = parseFloat(day.total_cost || 0);
const date = day.usage_date || `Day ${i+1}`;
totalCost += cost;
if (cost > 0) {
console.log(`๐
${date}: $${cost.toFixed(8)}`);
}
}
});
console.log(`\n๐ Week Total: $${totalCost.toFixed(8)}`);
console.log(`๐ Daily Average: $${(totalCost/7).toFixed(8)}`);
if (totalCost > 0) {
console.log('โ
Found CloudWatch costs - can extrapolate to 30 days');
const estimated30Day = (totalCost / 7) * 30;
console.log(`๐ Estimated 30-day cost: $${estimated30Day.toFixed(8)}`);
}
}
} catch (e) {
console.log('โ Parse error:', e.message);
}
}
}
} else {
console.log('โ No response');
}
server.kill();
}
getCloudWatchAug4Week().catch(console.error);