#!/usr/bin/env node
// Detailed Answers Test - Show full content of all responses
const { spawn } = require('child_process');
const { EventEmitter } = require('events');
class DetailedAnswersTest extends EventEmitter {
constructor() {
super();
this.serverProcess = null;
this.messageId = 1;
this.pendingRequests = new Map();
}
async startServer() {
console.log('π§ Starting MCP server for detailed answers test...');
this.serverProcess = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe']
});
this.serverProcess.stdout.on('data', (data) => {
const lines = data.toString().split('\n').filter(line => line.trim());
lines.forEach(line => {
try {
const message = JSON.parse(line);
this.handleMessage(message);
} catch (e) {}
});
});
this.serverProcess.stderr.on('data', (data) => {
// Suppress server logs for clean output
});
await new Promise(resolve => setTimeout(resolve, 2000));
console.log('β
MCP server ready for detailed testing');
}
handleMessage(message) {
if (message.id && this.pendingRequests.has(message.id)) {
const resolve = this.pendingRequests.get(message.id);
this.pendingRequests.delete(message.id);
resolve(message);
}
}
async sendRequest(method, params) {
const id = this.messageId++;
const request = { jsonrpc: '2.0', id, method, params };
return new Promise((resolve, reject) => {
this.pendingRequests.set(id, resolve);
this.serverProcess.stdin.write(JSON.stringify(request) + '\n');
setTimeout(() => {
if (this.pendingRequests.has(id)) {
this.pendingRequests.delete(id);
reject(new Error('Timeout'));
}
}, 20000);
});
}
async initialize() {
await this.sendRequest('initialize', {
protocolVersion: '2024-11-05',
capabilities: {},
clientInfo: { name: 'detailed-answers-tester', version: '1.0.0' }
});
}
async authenticate() {
const authResult = await this.sendRequest('tools/call', {
name: 'authenticate_user',
arguments: { username: 'david+saola@umbrellacost.com', password: 'Dsamsung1!' }
});
return authResult.result.content[0].text.includes('Successfully authenticated');
}
async testAllQuestionsDetailed() {
const questions = [
{
id: 'Q1',
name: 'list_endpoints',
args: {},
title: 'Available API Endpoints',
description: 'Shows all available Umbrella Cost API endpoints'
},
{
id: 'Q2',
name: 'api___msp_customers',
args: {},
title: 'MSP Customer List',
description: 'List of MSP customers (business entities)'
},
{
id: 'Q3',
name: 'api___user_management_accounts',
args: {},
title: 'All Available Accounts',
description: 'Complete inventory of cloud accounts'
},
{
id: 'Q4',
name: 'api___invoices_caui',
args: {
startDate: '2025-08-01',
endDate: '2025-08-18',
groupBy: 'service',
periodGranLevel: 'day'
},
title: 'Current Month Daily Costs',
description: 'Daily cost breakdown for current month'
},
{
id: 'Q5',
name: 'api___invoices_caui',
args: {
startDate: '2025-06-01',
endDate: '2025-08-18',
groupBy: 'none',
periodGranLevel: 'month',
cloud_context: 'aws'
},
title: 'AWS Monthly Cost Trends',
description: 'AWS costs aggregated by month (verified against UI)'
},
{
id: 'Q6',
name: 'api___invoices_caui',
args: {
startDate: '2025-03-01',
endDate: '2025-08-18',
groupBy: 'none',
periodGranLevel: 'month',
isUnblended: 'false', // Testing amortized costs
cloud_context: 'aws'
},
title: 'AWS Amortized Costs (Last 6 Months)',
description: 'AWS amortized costs including RI and savings plan benefits'
},
{
id: 'Q7',
name: 'api___invoices_caui',
args: {
startDate: '2025-08-01',
endDate: '2025-08-18',
groupBy: 'service',
cloud_context: 'aws'
},
title: 'AWS Service Breakdown',
description: 'AWS costs broken down by service'
},
{
id: 'Q8',
name: 'api___apiv2recommendationslist',
args: {},
title: 'Cost Optimization Recommendations',
description: 'AI-powered cost saving recommendations'
},
{
id: 'Q9',
name: 'api___anomaly_detection',
args: {
startDate: '2025-08-01',
endDate: '2025-08-18'
},
title: 'Cost Anomaly Detection',
description: 'Detection of unusual spending patterns'
},
{
id: 'Q10',
name: 'api___invoices_service_names_distinct',
args: { limit: 20 },
title: 'Available Services (Top 20)',
description: 'Most commonly used cloud services'
}
];
console.log('\\nπ DETAILED ANSWERS TEST - FULL CONTENT');
console.log('β'.repeat(100));
console.log('Testing all key questions with complete response details');
console.log('β'.repeat(100));
for (const question of questions) {
try {
console.log(`\\n${'β'.repeat(100)}`);
console.log(`π ${question.id}: ${question.title}`);
console.log(`π‘ ${question.description}`);
console.log(`π§ Tool: ${question.name}`);
console.log(`π Args: ${JSON.stringify(question.args, null, 2)}`);
console.log(`${'β'.repeat(100)}`);
const result = await this.sendRequest('tools/call', {
name: question.name,
arguments: question.args
});
const response = result.result.content[0].text;
console.log('\\nπ€ FULL DETAILED RESPONSE:');
console.log('β'.repeat(80));
console.log(response);
console.log('β'.repeat(80));
// Extract key metrics from response
const itemsMatch = response.match(/\\*\\*Results:\\*\\* (\\d+) items?/);
const totalMatch = response.match(/\\$([\\d,]+\\.\\d{2})/);
const savingsMatch = response.match(/\\$([\\d,]+\\.\\d{2}) annual savings/);
const accountsMatch = response.match(/(\\d+) accounts?/);
console.log('\\nπ KEY METRICS EXTRACTED:');
if (itemsMatch) console.log(` π Items: ${itemsMatch[1]}`);
if (totalMatch) console.log(` π° Cost: $${totalMatch[1]}`);
if (savingsMatch) console.log(` π‘ Savings: $${savingsMatch[1]} annually`);
if (accountsMatch) console.log(` π’ Accounts: ${accountsMatch[1]}`);
const responseLength = response.length;
console.log(` π Response Length: ${responseLength} characters`);
if (response.includes('β') || response.includes('Error')) {
console.log(' β οΈ Status: Contains error or limitation indicators');
} else if (responseLength > 500) {
console.log(' β
Status: Comprehensive successful response');
} else {
console.log(' β
Status: Successful response');
}
// Brief pause between questions
await new Promise(resolve => setTimeout(resolve, 1000));
} catch (error) {
console.log(`β ${question.id} FAILED: ${error.message}`);
}
}
console.log('\\nπππππππππππππππππππππππ');
console.log('π DETAILED ANSWERS TEST COMPLETE');
console.log('All questions tested with full response details shown');
console.log('πππππππππππππππππππππππ');
}
async disconnect() {
if (this.serverProcess) {
this.serverProcess.kill();
}
}
}
async function runDetailedAnswersTest() {
console.log('π DETAILED ANSWERS TEST');
console.log('Showing complete response content for all questions');
console.log('β'.repeat(100));
const tester = new DetailedAnswersTest();
try {
await tester.startServer();
await tester.initialize();
if (await tester.authenticate()) {
console.log('β
Authentication successful - proceeding with detailed test');
await tester.testAllQuestionsDetailed();
} else {
console.log('β Authentication failed');
}
} catch (error) {
console.error('β Test failed:', error.message);
} finally {
await tester.disconnect();
}
}
runDetailedAnswersTest();