Skip to main content
Glama
test-mcp-heatmap.cjs3 kB
const axios = require('axios'); async function testMcpHeatmap() { const MCP_BASE_URL = 'https://thy-location-plant-cities.trycloudflare.com'; const USERNAME = 'elisha+testmcpdev@anodot.com'; const PASSWORD = 'Test123!'; try { console.log('🔐 Step 1: Authenticating with MCP OAuth server...\n'); // Authenticate with MCP const authResponse = await axios.post(`${MCP_BASE_URL}/oauth/token`, { username: USERNAME, password: PASSWORD, grant_type: 'password' }, { httpsAgent: new (require('https').Agent)({ rejectUnauthorized: false }) }); const mcpToken = authResponse.data.access_token; console.log('✅ MCP authentication successful\n'); console.log('📊 Step 2: Calling heatmap endpoint through MCP...\n'); // Call MCP tool to get heatmap const mcpRequest = { jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'umbrella_api_call', arguments: { path: '/v1/recommendationsNew/heatmap/summary', method: 'GET' } } }; const mcpResponse = await axios.post(`${MCP_BASE_URL}/mcp`, mcpRequest, { headers: { 'Authorization': `Bearer ${mcpToken}`, 'Content-Type': 'application/json' }, httpsAgent: new (require('https').Agent)({ rejectUnauthorized: false }) }); console.log('✅ MCP response received\n'); // Parse the result const result = mcpResponse.data.result; if (result.isError) { console.error('❌ MCP returned error:', result.content[0].text); return; } // Extract data from MCP response const responseText = result.content[0].text; const jsonMatch = responseText.match(/```json\n([\s\S]*?)\n```/); if (!jsonMatch) { console.log('Response text:', responseText); return; } const heatmapData = JSON.parse(jsonMatch[1]); console.log('=== HEATMAP RESULTS FROM MCP ==='); console.log(`Potential Annual Savings: $${heatmapData.potentialAnnualSavings?.toFixed(2) || 0}`); console.log(`Actual Annual Savings: $${heatmapData.actualAnnualSavings?.toFixed(2) || 0}`); console.log(`Total Count: ${heatmapData.totalCount || 0}`); console.log(`\n✅ Expected: Potential ~$32K, Actual ~$3.28M`); // Verify values const potentialOk = heatmapData.potentialAnnualSavings >= 30000 && heatmapData.potentialAnnualSavings <= 35000; const actualOk = heatmapData.actualAnnualSavings >= 3000000 && heatmapData.actualAnnualSavings <= 3500000; console.log(`\n📊 Validation:`); console.log(` Potential savings in range: ${potentialOk ? '✅' : '❌'}`); console.log(` Actual savings in range: ${actualOk ? '✅' : '❌'}`); } catch (error) { console.error('❌ Error:', error.response?.data || error.message); if (error.response?.data) { console.error('Response data:', JSON.stringify(error.response.data, null, 2)); } } } testMcpHeatmap();

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