Skip to main content
Glama
compare-caui-vs-recommendations.cjs5.69 kB
#!/usr/bin/env node /** * COMPARE CAUI vs RECOMMENDATIONS - SAME SESSION * ================================================ * * Test why CAUI works but recommendations doesn't with the same OAuth session */ const { Client } = require('@modelcontextprotocol/sdk/client/index.js'); const { StdioClientTransport } = require('@modelcontextprotocol/sdk/client/stdio.js'); console.log('🔬 COMPARING CAUI vs RECOMMENDATIONS - SAME SESSION'); console.log('='.repeat(70)); async function compareAPIs() { const transport = new StdioClientTransport({ command: 'node', args: ['/Users/david/Downloads/MCP/UmbrellaMCP/dist/index.js'], env: { ...process.env, UMBRELLA_BASE_URL: 'https://umbrellacost.io', DEBUG: 'true' } }); const client = new Client( { name: 'api-comparison-client', version: '1.0.0' }, { capabilities: {} } ); try { await client.connect(transport); console.log('✅ Connected to MCP server'); // Step 1: OAuth Authentication (creates session) console.log('\n🔐 STEP 1: OAuth Authentication'); console.log('-'.repeat(40)); const authResult = await client.request({ method: 'tools/call', params: { name: 'oauth_authenticate', arguments: { username: 'david+allcloud@umbrellacost.com', password: process.env.UMBRELLA_PASSWORD || 'defaultPassword' } } }); if (!authResult.content?.[0]?.text?.includes('successfully')) { throw new Error('OAuth authentication failed'); } console.log('✅ OAuth authentication successful'); console.log('📝 This creates ONE session that both APIs will use'); // Step 2: Call CAUI API console.log('\n🏦 STEP 2: CAUI API Call'); console.log('-'.repeat(40)); console.log('Tool: api__invoices_caui'); console.log('Query: "show Bank Leumi BL Test Env costs"'); const cauiResult = await client.request({ method: 'tools/call', params: { name: 'api__invoices_caui', arguments: { userQuery: 'show Bank Leumi BL Test Env costs' } } }); let cauiWorked = false; if (cauiResult.content?.[0]?.text) { const cauiText = cauiResult.content[0].text; if (cauiText.includes('57ade50e-c9a8-49f3-8ce7-28d44536a669:24223:1')) { console.log('✅ CAUI WORKED - Found correct API key for Bank Leumi (24223)'); cauiWorked = true; } else { console.log('❌ CAUI FAILED - No Bank Leumi API key found'); } } // Step 3: Call Recommendations API (same session) console.log('\n🎯 STEP 3: Recommendations API Call (SAME SESSION)'); console.log('-'.repeat(55)); console.log('Tool: api__api_v2_recommendations_list'); console.log('Query: "show Bank Leumi BL Test Env recommendations"'); const recResult = await client.request({ method: 'tools/call', params: { name: 'api__api_v2_recommendations_list', arguments: { userQuery: 'show Bank Leumi BL Test Env recommendations' } } }); let recWorked = false; if (recResult.content?.[0]?.text) { const recText = recResult.content[0].text; if (recText.includes('57ade50e-c9a8-49f3-8ce7-28d44536a669:24223:1')) { console.log('✅ RECOMMENDATIONS WORKED - Found correct API key for Bank Leumi (24223)'); recWorked = true; } else { console.log('❌ RECOMMENDATIONS FAILED - No Bank Leumi API key found'); if (recText.includes('No recommendations data received')) { console.log(' Error: "No recommendations data received"'); } } } // Step 4: Analysis console.log('\n' + '='.repeat(70)); console.log('📊 RESULTS SUMMARY:'); console.log('='.repeat(70)); console.log(`CAUI API: ${cauiWorked ? '✅ WORKS' : '❌ FAILS'}`); console.log(`Recommendations API: ${recWorked ? '✅ WORKS' : '❌ FAILS'}`); if (cauiWorked && !recWorked) { console.log('\n🔍 KEY FINDING:'); console.log('Both APIs use the SAME OAuth session and SAME auth headers.'); console.log('Both APIs call detectCustomerFromQuery() with the SAME logic.'); console.log('But CAUI works and Recommendations doesn\'t!'); console.log('\n💡 POSSIBLE CAUSES:'); console.log('1. The recommendations endpoint itself might have different requirements'); console.log('2. The API response handling might be different'); console.log('3. There might be a bug in how recommendations processes the API key'); console.log('4. The session state might be modified between calls somehow'); } } catch (error) { console.error('\n💥 Test failed:', error.message); } finally { try { await client.close(); } catch (e) { // Ignore close errors } } } compareAPIs().then(() => { console.log('\n' + '='.repeat(70)); console.log('🏁 COMPARISON COMPLETE'); }).catch(error => { console.error('❌ Fatal error:', error.message); process.exit(1); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daviddraiumbrella/invoice-monitoring'

If you have feedback or need assistance with the MCP directory API, please join our Discord server