#!/usr/bin/env node
const { spawn } = require('child_process');
async function getTestAnswers() {
console.log('📋 MCP SERVER TEST QUESTION ANSWERS');
console.log('═'.repeat(80));
const server = spawn('node', ['dist/index.js'], { stdio: ['pipe', 'pipe', 'pipe'] });
let messageId = 1;
let responses = new Map();
server.stdout.on('data', (data) => {
const lines = data.toString().split('\n').filter(l => l.trim());
lines.forEach(line => {
try {
const msg = JSON.parse(line);
if (msg.id) responses.set(msg.id, msg);
} catch(e) {}
});
});
// Show server logs for debugging
server.stderr.on('data', (data) => {
const logMsg = data.toString().trim();
if (logMsg.includes('[AUTO-SELECT]')) {
console.log('🔧', logMsg);
}
});
await new Promise(r => setTimeout(r, 2000));
// Initialize
server.stdin.write(JSON.stringify({
jsonrpc: '2.0',
id: messageId++,
method: 'initialize',
params: {
protocolVersion: '2024-11-05',
capabilities: {},
clientInfo: { name: 'answers-test', version: '1.0.0' }
}
}) + '\n');
await new Promise(r => setTimeout(r, 1000));
// Authenticate
const authId = messageId++;
server.stdin.write(JSON.stringify({
jsonrpc: '2.0',
id: authId,
method: 'tools/call',
params: {
name: 'authenticate_user',
arguments: {
username: 'david+saola@umbrellacost.com',
password: 'Dsamsung1!'
}
}
}) + '\n');
await new Promise(r => setTimeout(r, 4000));
// Test questions without accountId
const questions = [
{
q: 'what is my total cost?',
tool: 'api__invoices_caui',
args: {
startDate: '2025-08-11',
endDate: '2025-08-17',
groupBy: 'service',
periodGranLevel: 'day'
}
},
{
q: 'show me total cost by month',
tool: 'api__invoices_caui',
args: {
startDate: '2025-02-01',
endDate: '2025-08-17',
groupBy: 'none',
periodGranLevel: 'month'
}
},
{
q: 'what do you recommend to do for saving AWS costs?',
tool: 'api__recommendations_report',
args: {}
}
];
// Test each question and show full answers
for (let i = 0; i < questions.length; i++) {
const question = questions[i];
console.log('\n' + '═'.repeat(80));
console.log(`❓ Q${i + 1}: "${question.q}"`);
console.log(`🔧 Tool: ${question.tool}`);
console.log('═'.repeat(80));
const questionId = messageId++;
server.stdin.write(JSON.stringify({
jsonrpc: '2.0',
id: questionId,
method: 'tools/call',
params: {
name: question.tool,
arguments: question.args
}
}) + '\n');
await new Promise(r => setTimeout(r, 8000));
const response = responses.get(questionId);
if (response && response.result) {
console.log('\n🤖 CLAUDE DESKTOP ANSWER:');
console.log(response.result.content[0].text);
} else {
console.log('\n❌ NO ANSWER RECEIVED');
if (response && response.error) {
console.log(`Error: ${response.error.message}`);
}
}
}
server.kill();
}
getTestAnswers().catch(console.error);