Skip to main content
Glama
analyze-recommendations-flow.cjs•3.71 kB
#!/usr/bin/env node /** * ANALYSIS: Why recommendations API is not using customer-specific API key * * PROBLEM FOUND: * The customer detection WORKS - it correctly identifies Bank Leumi (account 24223) * BUT the API client is not receiving the customer_account_key parameter * * FLOW: * 1. ✅ Tool call: api__api_v2_recommendations_list with userQuery * 2. ✅ handleApiCall receives the request * 3. ✅ detectCustomerFromQuery identifies Bank Leumi (should set customer_account_key=22676) * 4. ❌ makeRequest is not receiving customer_account_key in params * 5. ❌ getAuthHeaders falls back to default API key * 6. ❌ API returns 500 error because wrong account * * ROOT CAUSE: * The customer detection happens but the customer_account_key is not being passed * through to the api-client's makeRequest method. * * SOLUTION NEEDED: * Ensure that when detectCustomerFromQuery sets customer_account_key and * customer_division_id, these are included in the params passed to makeRequest. */ console.log('='.repeat(80)); console.log('RECOMMENDATIONS API FLOW ANALYSIS'); console.log('='.repeat(80)); console.log('\n🔍 PROBLEM IDENTIFIED:'); console.log('-------------------'); console.log('The /api/v2/recommendations/list endpoint is not using the customer-specific API key'); console.log('even though customer detection is working correctly.\n'); console.log('📍 EVIDENCE FROM LOGS:'); console.log('1. Customer detection should happen (path includes /recommendations)'); console.log('2. But API client logs show: "Using default API key" instead of customer key'); console.log('3. API fails with 500 error because it\'s using wrong account (15808 instead of 24223)\n'); console.log('🔧 THE FIX LOCATION:'); console.log('/Users/david/Downloads/MCP/UmbrellaMCP/src/server.ts'); console.log('Around line 927 where makeRequest is called'); console.log('\nThe validatedParams object should contain:'); console.log('- customer_account_key: "22676" (for Bank Leumi)'); console.log('- customer_division_id: "1" (for BL Test Env)'); console.log('\nThese MUST be passed to makeRequest for the API key to be built correctly.\n'); console.log('📝 VERIFICATION STEPS:'); console.log('1. Check if detectCustomerFromQuery is actually being called for /api/v2/recommendations/list'); console.log('2. Verify that customer_account_key is being set in validatedParams'); console.log('3. Ensure these params are passed to session.apiClient.makeRequest()'); console.log('4. Confirm getAuthHeaders receives customerAccountKey parameter\n'); console.log('🎯 EXPECTED FLOW FOR MSP USERS:'); console.log('1. Tool: api__api_v2_recommendations_list with userQuery="Bank Leumi BL Test Env"'); console.log('2. Server: detectCustomerFromQuery finds account 24223, key 22676'); console.log('3. Server: Sets customer_account_key=22676, customer_division_id=1'); console.log('4. ApiClient: Receives these params in makeRequest'); console.log('5. ApiClient: getAuthHeaders builds key: 57ade50e-c9a8-49f3-8ce7-28d44536a669:22676:1'); console.log('6. API: Returns recommendations for Bank Leumi BL Test Env\n'); console.log('❌ ACTUAL FLOW (BROKEN):'); console.log('1. Tool: api__api_v2_recommendations_list with userQuery="Bank Leumi BL Test Env"'); console.log('2. Server: detectCustomerFromQuery might run but result not used?'); console.log('3. ApiClient: No customer_account_key received'); console.log('4. ApiClient: Falls back to default key: 57ade50e-c9a8-49f3-8ce7-28d44536a669:15808:0'); console.log('5. API: Returns 500 error\n'); console.log('='.repeat(80)); console.log('NEXT STEP: Check server.ts to see why customer params are not passed to makeRequest'); console.log('='.repeat(80));

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