Skip to main content
Glama
investigate-parameter-override.cjs5.71 kB
const fs = require('fs'); const path = require('path'); function analyzeCustomerDetectionFlow() { console.log('🔍 Analyzing Customer Detection Parameter Override Logic\n'); // Read the server.ts file to examine the detection logic const serverPath = path.join(__dirname, '../../src/server.ts'); const serverContent = fs.readFileSync(serverPath, 'utf8'); // Find the customer detection logic const lines = serverContent.split('\n'); console.log('🔎 Looking for customer detection logic...\n'); let inDetectionFunction = false; let detectionStartLine = 0; let detectionEndLine = 0; for (let i = 0; i < lines.length; i++) { const line = lines[i]; // Look for the main detection function or logic if (line.includes('detectCustomerFromQuery') || line.includes('customer detection') || line.includes('CUSTOMER-DETECTION')) { if (!inDetectionFunction) { inDetectionFunction = true; detectionStartLine = i; console.log(`📍 Found detection logic at line ${i + 1}:`); console.log(` ${line.trim()}`); } } // Look for where parameters are applied or overridden if (line.includes('customer_account_key') && (line.includes('currentParams') || line.includes('provided') || line.includes('Claude'))) { console.log(`🎯 Parameter handling at line ${i + 1}:`); console.log(` ${line.trim()}`); // Show surrounding context for (let j = Math.max(0, i - 2); j <= Math.min(lines.length - 1, i + 2); j++) { if (j !== i) { console.log(` ${j + 1}: ${lines[j].trim()}`); } } console.log(''); } // Look for where detection results are applied if (line.includes('detectedApiKey') || line.includes('detection result') || (line.includes('apikey') && line.includes('='))) { console.log(`⚙️ Detection result application at line ${i + 1}:`); console.log(` ${line.trim()}`); } } console.log('\n🔍 Key Questions to Answer:'); console.log('1. Where exactly does customer detection run?'); console.log('2. How are the detection results applied to parameters?'); console.log('3. Does the current fix actually override provided customer_account_key?'); console.log('4. Are there multiple places where customer_account_key could be set?'); // Look for the specific patterns we implemented console.log('\n🎯 Looking for our implemented fix patterns...\n'); const fixPatterns = [ 'Claude provided customer_account_key', 'but will run detection anyway', 'always run customer detection', 'regardless of provided' ]; fixPatterns.forEach(pattern => { const found = lines.find((line, idx) => { if (line.toLowerCase().includes(pattern.toLowerCase())) { console.log(`✅ Found fix pattern "${pattern}" at line ${idx + 1}:`); console.log(` ${line.trim()}`); return true; } return false; }); if (!found) { console.log(`❌ Fix pattern "${pattern}" NOT found`); } }); console.log('\n🧪 Simulation: What should happen with "Bank Leumi Test Env" query?'); console.log('Input:'); console.log(' - Query: "show me Bank Leumi Test Env costs last 6 months"'); console.log(' - Claude provides: customer_account_key: "22676"'); console.log(' - Available accounts: 22676 (Reseller-1), 24223 (BL Test Env)'); console.log(''); console.log('Expected behavior with our fix:'); console.log(' 1. Claude provides customer_account_key: "22676"'); console.log(' 2. Our code logs: "Claude provided customer_account_key: 22676, but will run detection anyway"'); console.log(' 3. Detection runs on query words: ["bank", "leumi", "test", "env"]'); console.log(' 4. Detection finds "BL Test Env" as better match than "Reseller-1"'); console.log(' 5. Final API key should be: 57ade50e-c9a8-49f3-8ce7-28d44536a669:24223:1'); console.log(''); console.log('🚨 If this is not happening, the issue could be:'); console.log(' A) Detection logic not running at all'); console.log(' B) Detection running but results not applied'); console.log(' C) Parameters being overridden after detection'); console.log(' D) Multiple detection calls with different results'); } function checkForMultipleDetectionCalls() { console.log('\n🔄 Checking for multiple customer detection calls...\n'); const serverPath = path.join(__dirname, '../../src/server.ts'); const serverContent = fs.readFileSync(serverPath, 'utf8'); const lines = serverContent.split('\n'); const detectionCalls = []; lines.forEach((line, idx) => { if (line.includes('detectCustomerFromQuery') || line.includes('customer detection') || line.includes('CUSTOMER-DETECTION')) { detectionCalls.push({ line: idx + 1, content: line.trim() }); } }); console.log(`Found ${detectionCalls.length} potential detection call sites:`); detectionCalls.forEach(call => { console.log(` Line ${call.line}: ${call.content}`); }); if (detectionCalls.length > 3) { console.log('\n⚠️ WARNING: Multiple detection calls found - could cause conflicts'); } } function checkCurrentServerStatus() { console.log('\n🌐 Current Server Status:'); console.log(' Tunnel URL: https://opposition-mailing-damaged-chronic.trycloudflare.com/mcp'); console.log(' Server should be running with the latest fix'); console.log(' Ready for testing with Claude Desktop'); } // Run the analysis analyzeCustomerDetectionFlow(); checkForMultipleDetectionCalls(); checkCurrentServerStatus();

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