Skip to main content
Glama
test-current-detection-fix.cjs4.57 kB
const https = require('https'); // Test configuration const MCP_ENDPOINT = 'https://wireless-humanities-reality-batch.trycloudflare.com/mcp'; const AUTH_TOKEN = process.env.AUTH_TOKEN; async function makeRequest(body) { return new Promise((resolve, reject) => { const url = new URL(MCP_ENDPOINT); const options = { hostname: url.hostname, port: url.port || 443, path: url.pathname, method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': AUTH_TOKEN ? `Bearer ${AUTH_TOKEN}` : undefined, 'Accept': 'application/json, text/event-stream' } }; const req = https.request(options, (res) => { let data = ''; res.on('data', (chunk) => data += chunk); res.on('end', () => { try { resolve(JSON.parse(data)); } catch (e) { resolve(data); } }); }); req.on('error', reject); req.write(JSON.stringify(body)); req.end(); }); } async function testDetectionFix() { console.log('🔍 Testing Customer Detection Fix\n'); // Test cases that should trigger different detection behavior const testCases = [ { name: "Bank Leumi Test Env (should detect account 24223)", query: "show me Bank Leumi Test Env costs last 6 months", providedAccountKey: "22676", // Wrong key that Claude sends expectedAccount: "24223" }, { name: "BL Test Env (should detect account 24223)", query: "show me BL Test Env costs last 6 months", providedAccountKey: "22676", // Wrong key that Claude sends expectedAccount: "24223" }, { name: "Bank Leumi main (should keep 22676)", query: "show me Bank Leumi costs last 6 months", providedAccountKey: null, // No key provided expectedAccount: "22676" } ]; for (const testCase of testCases) { console.log(`\n=== Testing: ${testCase.name} ===`); console.log(`Query: "${testCase.query}"`); console.log(`Provided Account Key: ${testCase.providedAccountKey || 'none'}`); console.log(`Expected Account: ${testCase.expectedAccount}`); const requestArgs = { accountId: '696314371547', startDate: '2025-03-01', endDate: '2025-09-26', periodGranLevel: 'month', groupBy: 'none', costType: '["cost", "discount"]', userQuery: testCase.query }; // Add the wrong customer account key if specified (simulating Claude's behavior) if (testCase.providedAccountKey) { requestArgs.customer_account_key = testCase.providedAccountKey; } const request = { jsonrpc: '2.0', method: 'tools/call', params: { name: 'api__invoices_caui', arguments: requestArgs }, id: Math.floor(Math.random() * 1000) }; try { const response = await makeRequest(request); if (response.result) { const responseStr = JSON.stringify(response.result); // Look for API key patterns const apiKeyMatch = responseStr.match(/([a-f0-9-]{36}):(\\d+):(\\d+)/); if (apiKeyMatch) { const [fullKey, uuid, accountKey, divisionFlag] = apiKeyMatch; console.log(`✅ API Key Found: ${fullKey}`); console.log(` Account Key: ${accountKey}`); console.log(` Division Flag: ${divisionFlag}`); if (accountKey === testCase.expectedAccount) { console.log(`✅ SUCCESS: Account key matches expected ${testCase.expectedAccount}`); } else { console.log(`❌ FAILED: Account key ${accountKey} != expected ${testCase.expectedAccount}`); } } else { console.log('❌ No API key pattern found in response'); } // Look for evidence of customer detection override if (responseStr.includes('Claude provided customer_account_key')) { console.log('📍 Customer detection override triggered'); } } else if (response.error) { console.log('❌ Error:', response.error.message); } } catch (error) { console.error('❌ Request failed:', error.message); } // Wait between requests await new Promise(resolve => setTimeout(resolve, 1000)); } } // Check if auth token is provided if (!AUTH_TOKEN) { console.error('Please provide AUTH_TOKEN environment variable'); console.error('Usage: AUTH_TOKEN="Bearer eyJ..." node test-current-detection-fix.cjs'); process.exit(1); } testDetectionFix().catch(console.error);

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