const fetch = require('node-fetch');
// Disable SSL verification for local testing
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
const serverUrl = 'https://localhost:3003';
const https = require('https');
// No need for USERNAME/PASSWORD - we'll use the already authenticated MCP server
async function callMCPMethod(method, params) {
// The local MCP server is already authenticated via OAuth from Claude Desktop
const response = await fetch(`${serverUrl}/mcp`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
method,
params,
jsonrpc: '2.0',
id: 1
}),
agent: new https.Agent({
rejectUnauthorized: false
})
});
return await response.json();
}
async function testBankLeumiRecommendations() {
console.log('\n🚀 Testing Bank Leumi Recommendations via Local MCP\n');
console.log('=' .repeat(70));
console.log('ℹ️ Using already authenticated local MCP server on port 3003\n');
// Test 1: Default parameters (should be open only)
console.log('📊 Test 1: Bank Leumi BL Test Env - DEFAULT (should be open only)');
console.log('-'.repeat(70));
const result1 = await callMCPMethod('tools/call', {
name: 'get_all_recommendations',
arguments: {
userQuery: 'show me recommendations for Bank Leumi BL Test Env',
daysBack: 30,
pageSize: 100 // Larger page to see more items
// NOT setting includeClosedAndDone - should default to false
}
});
if (result1.result && result1.result.content && result1.result.content[0]) {
const content = result1.result.content[0].text;
// Extract key information
const statusMatch = content.match(/\*\*Status Filter:\*\* ([^\n]+)/);
const totalMatch = content.match(/\*\*Total Recommendations:\*\* (\d+)/);
const savingsMatch = content.match(/\*\*Total Potential Savings:\*\* \$[\d,]+\.\d{2}/);
const customerMatch = content.match(/\*\*Customer:\*\* ([^\n]+)/);
console.log('🔍 Results:');
if (statusMatch) console.log(` Status Filter: ${statusMatch[1]}`);
if (totalMatch) console.log(` Total Recommendations: ${totalMatch[1]}`);
if (savingsMatch) console.log(` Total Savings: ${savingsMatch[0].replace(/\*\*/g, '')}`);
if (customerMatch) console.log(` Customer: ${customerMatch[1]}`);
// Show first few recommendations
const recsMatch = content.match(/## Top \d+ Recommendations by Savings:[\s\S]*?(?=##|$)/);
if (recsMatch) {
console.log('\n First few recommendations:');
const recs = recsMatch[0].split(/\d+\.\s+\*\*/).slice(1, 4);
recs.forEach((rec, i) => {
const lines = rec.split('\n').filter(l => l.trim());
if (lines[0]) {
console.log(` ${i + 1}. ${lines[0].replace(/\*\*/g, '').trim()}`);
}
});
}
} else if (result1.error) {
console.log('❌ Error:', result1.error.message || result1.error);
}
// Test 2: Explicitly set to open only
console.log('\n\n📊 Test 2: Bank Leumi BL Test Env - EXPLICIT open only (includeClosedAndDone: false)');
console.log('-'.repeat(70));
const result2 = await callMCPMethod('tools/call', {
name: 'get_all_recommendations',
arguments: {
userQuery: 'show me recommendations for Bank Leumi BL Test Env',
daysBack: 30,
pageSize: 100,
includeClosedAndDone: false // Explicitly set to false
}
});
if (result2.result && result2.result.content && result2.result.content[0]) {
const content = result2.result.content[0].text;
const totalMatch = content.match(/\*\*Total Recommendations:\*\* (\d+)/);
const savingsMatch = content.match(/\*\*Total Potential Savings:\*\* \$[\d,]+\.\d{2}/);
const statusMatch = content.match(/\*\*Status Filter:\*\* ([^\n]+)/);
console.log('🔍 Results:');
if (statusMatch) console.log(` Status Filter: ${statusMatch[1]}`);
if (totalMatch) console.log(` Total Recommendations: ${totalMatch[1]}`);
if (savingsMatch) console.log(` Total Savings: ${savingsMatch[0].replace(/\*\*/g, '')}`);
} else if (result2.error) {
console.log('❌ Error:', result2.error.message || result2.error);
}
// Test 3: Include closed and done
console.log('\n\n📊 Test 3: Bank Leumi BL Test Env - INCLUDING closed/done (includeClosedAndDone: true)');
console.log('-'.repeat(70));
const result3 = await callMCPMethod('tools/call', {
name: 'get_all_recommendations',
arguments: {
userQuery: 'show me recommendations for Bank Leumi BL Test Env',
daysBack: 30,
pageSize: 100,
includeClosedAndDone: true // Include closed and done
}
});
if (result3.result && result3.result.content && result3.result.content[0]) {
const content = result3.result.content[0].text;
const statusMatch = content.match(/\*\*Status Filter:\*\* ([^\n]+)/);
const totalMatch = content.match(/\*\*Total Recommendations:\*\* (\d+)/);
const savingsMatch = content.match(/\*\*Total Potential Savings:\*\* \$[\d,]+\.\d{2}/);
console.log('🔍 Results:');
if (statusMatch) console.log(` Status Filter: ${statusMatch[1]}`);
if (totalMatch) console.log(` Total Recommendations: ${totalMatch[1]}`);
if (savingsMatch) console.log(` Total Savings: ${savingsMatch[0].replace(/\*\*/g, '')}`);
} else if (result3.error) {
console.log('❌ Error:', result3.error.message || result3.error);
}
// Test 4: Try the production account (696314371547)
console.log('\n\n📊 Test 4: Bank Leumi PRODUCTION (account 696314371547, division 139)');
console.log('-'.repeat(70));
const result4 = await callMCPMethod('tools/call', {
name: 'get_all_recommendations',
arguments: {
userQuery: 'show me recommendations for Bank Leumi account 696314371547',
daysBack: 30,
pageSize: 100,
includeClosedAndDone: false // Only open
}
});
if (result4.result && result4.result.content && result4.result.content[0]) {
const content = result4.result.content[0].text;
const totalMatch = content.match(/\*\*Total Recommendations:\*\* (\d+)/);
const savingsMatch = content.match(/\*\*Total Potential Savings:\*\* \$[\d,]+\.\d{2}/);
const customerMatch = content.match(/\*\*Customer:\*\* ([^\n]+)/);
console.log('🔍 Results:');
if (customerMatch) console.log(` Customer: ${customerMatch[1]}`);
if (totalMatch) console.log(` Total Recommendations: ${totalMatch[1]}`);
if (savingsMatch) console.log(` Total Savings: ${savingsMatch[0].replace(/\*\*/g, '')}`);
// Show top recommendations
const recsMatch = content.match(/## Top \d+ Recommendations by Savings:[\s\S]*?(?=##|$)/);
if (recsMatch) {
console.log('\n First few recommendations:');
const recs = recsMatch[0].split(/\d+\.\s+\*\*/).slice(1, 4);
recs.forEach((rec, i) => {
const lines = rec.split('\n').filter(l => l.trim());
if (lines[0]) {
console.log(` ${i + 1}. ${lines[0].replace(/\*\*/g, '').trim()}`);
}
});
}
} else if (result4.error) {
console.log('❌ Error:', result4.error.message || result4.error);
}
// Test 5: Try with just "Bank Leumi" to see what happens
console.log('\n\n📊 Test 5: Generic "Bank Leumi" query (no specific account)');
console.log('-'.repeat(70));
const result5 = await callMCPMethod('tools/call', {
name: 'get_all_recommendations',
arguments: {
userQuery: 'show me recommendations for Bank Leumi',
daysBack: 30,
pageSize: 50,
includeClosedAndDone: false
}
});
if (result5.result && result5.result.content && result5.result.content[0]) {
const content = result5.result.content[0].text;
const totalMatch = content.match(/\*\*Total Recommendations:\*\* (\d+)/);
const savingsMatch = content.match(/\*\*Total Potential Savings:\*\* \$[\d,]+\.\d{2}/);
const customerMatch = content.match(/\*\*Customer:\*\* ([^\n]+)/);
console.log('🔍 Results:');
if (customerMatch) console.log(` Customer: ${customerMatch[1]}`);
if (totalMatch) console.log(` Total Recommendations: ${totalMatch[1]}`);
if (savingsMatch) console.log(` Total Savings: ${savingsMatch[0].replace(/\*\*/g, '')}`);
} else if (result5.error) {
console.log('❌ Error:', result5.error.message || result5.error);
}
console.log('\n' + '=' .repeat(70));
console.log('✅ Debug testing completed!\n');
console.log('📝 Summary:');
console.log(' - Check if default parameters work correctly (open only)');
console.log(' - Compare open vs closed/done recommendation counts');
console.log(' - Verify customer detection for different Bank Leumi accounts');
console.log('\n');
}
async function main() {
try {
// First check if the local MCP server is running
console.log('🔍 Checking if local MCP server is running on port 3003...');
try {
const testResponse = await fetch(`${serverUrl}/mcp`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
method: 'tools/list',
params: {},
jsonrpc: '2.0',
id: 1
}),
agent: new https.Agent({
rejectUnauthorized: false
})
});
if (testResponse.ok) {
console.log('✅ Local MCP server is running!\n');
await testBankLeumiRecommendations();
} else {
console.log('❌ Local MCP server returned an error. Make sure it\'s authenticated.');
console.log(' Run: PORT=3003 ./start-local-mcp.sh');
}
} catch (connectError) {
console.log('❌ Cannot connect to local MCP server on port 3003');
console.log(' Please ensure the server is running:');
console.log(' Run: PORT=3003 ./start-local-mcp.sh');
}
} catch (error) {
console.error('❌ Error:', error.message);
console.error(error.stack);
}
}
main();