Skip to main content
Glama
test-anomaly-like-mcp.cjs3.35 kB
const axios = require('axios'); async function testAnomalyLikeMCP() { const BASE_URL = 'https://api.dev.umbrellacost.dev/api'; const USERNAME = 'elisha+testmcpdev@anodot.com'; const PASSWORD = 'Test123!'; const ACCOUNT_KEY = '111111639'; const DIVISION_ID = '0'; try { console.log('🔐 Authenticating...\n'); const authResponse = await axios.post(`${BASE_URL}/v1/users/signin`, { username: USERNAME, password: PASSWORD }); const token = authResponse.data.jwtToken; const tokenPayload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString()); const userKey = tokenPayload.sub; console.log('✅ Authenticated'); console.log(`User Key: ${userKey}\n`); // Simulate what MCP server does - it gets these parameters from Claude const mcpParams = { accountKey: ACCOUNT_KEY, divisionId: DIVISION_ID, startDate: '2025-09-01', endDate: '2025-10-07', isPpApplied: false }; console.log('📊 Testing anomaly-detection like MCP would call it...'); console.log('MCP Parameters:', mcpParams); console.log(''); // Build API key the way MCP does (after our fix) const divisionIdNum = parseInt(String(mcpParams.divisionId), 10); const apiKey = `${userKey}:${mcpParams.accountKey}:${divisionIdNum}`; console.log(`Built API Key: ${apiKey}`); console.log(''); // Make the request with query parameters (not accountKey/divisionId) const queryParams = { startDate: mcpParams.startDate, endDate: mcpParams.endDate, isPpApplied: mcpParams.isPpApplied }; console.log('Query Parameters (sent to API):', queryParams); console.log(''); const response = await axios.get(`${BASE_URL}/v1/anomaly-detection`, { params: queryParams, headers: { 'Authorization': token, 'apikey': apiKey, 'Content-Type': 'application/json' } }); console.log('✅ Response received\n'); console.log('=== RESPONSE ==='); console.log(`Status: ${response.status}`); if (response.data && response.data.anomalies) { console.log(`Anomalies count: ${response.data.anomalies.length}`); if (response.data.anomalies.length > 0) { console.log('\n✅ SUCCESS! Anomalies returned:\n'); response.data.anomalies.forEach((anomaly, i) => { console.log(`${i + 1}. ${anomaly.uuid}`); console.log(` Account: ${anomaly.accountId}`); console.log(` Service: ${anomaly.serviceName}`); console.log(` Type: ${anomaly.anomalyType}`); console.log(` Current Cost: $${anomaly.currentCost?.toFixed(2)}`); console.log(` Total Cost Impact: $${anomaly.totalCostImpact?.toFixed(2)}`); console.log(` Percent Change: ${anomaly.percentChange?.toFixed(2)}%`); console.log(''); }); } else { console.log('\n⚠️ No anomalies in response (empty array)'); } } else { console.log('\n❌ Unexpected response structure:'); console.log(JSON.stringify(response.data, null, 2)); } } catch (error) { console.error('❌ Error:', error.message); if (error.response) { console.error('Status:', error.response.status); console.error('Data:', error.response.data); } } } testAnomalyLikeMCP();

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