Skip to main content
Glama
show-api-values.cjs5.93 kB
#!/usr/bin/env node const axios = require('axios'); const https = require('https'); const fs = require('fs'); // Create axios instance const axiosInstance = axios.create({ httpsAgent: new https.Agent({ rejectUnauthorized: false }), timeout: 30000 }); const MCP_BASE = 'https://faqs-papua-reflects-locked.trycloudflare.com'; async function fetchAndShowValues() { try { console.log('Fetching data from MCP API...\n'); // Make a simple query const response = await axiosInstance.post(`${MCP_BASE}/sse`, { jsonrpc: '2.0', method: 'tools/call', params: { name: 'api__invoices_caui', arguments: { prompt: 'Show me the costs for Saola' } }, id: 1 }, { headers: { 'Authorization': 'Bearer dummy', 'apikey': 'dummy' } }); // Parse SSE response const lines = response.data.split('\n'); for (const line of lines) { if (line.startsWith('data: ')) { try { const data = JSON.parse(line.slice(6)); if (data.result?.content?.[0]?.text) { const text = data.result.content[0].text; // Extract JSON from markdown code block const jsonMatch = text.match(/```json\s*\n(\[[\s\S]*?\])\s*\n```/); if (jsonMatch) { const jsonData = JSON.parse(jsonMatch[1]); console.log('=== RAW JSON DATA FROM API ===\n'); console.log('Total items in response:', jsonData.length); console.log('\nFirst 10 data points:'); console.log('----------------------'); jsonData.slice(0, 10).forEach((item, i) => { console.log(`\n${i + 1}. Item ${i + 1}:`); console.log(` usage_date: ${item.usage_date}`); console.log(` total_cost: ${item.total_cost}`); console.log(` account_id: ${item.account_id || 'N/A'}`); console.log(` account_name: ${item.account_name || 'N/A'}`); // Show any other fields const otherKeys = Object.keys(item).filter(k => !['usage_date', 'total_cost', 'account_id', 'account_name'].includes(k) ); if (otherKeys.length > 0) { otherKeys.forEach(key => { console.log(` ${key}: ${item[key]}`); }); } }); console.log('\n=== UNIQUE VALUES IN RESPONSE ===\n'); // Show unique total_cost values const uniqueCosts = [...new Set(jsonData.map(item => item.total_cost))]; console.log('Unique total_cost values:'); uniqueCosts.slice(0, 10).forEach((cost, i) => { console.log(` ${i + 1}. ${cost}`); }); if (uniqueCosts.length > 10) { console.log(` ... and ${uniqueCosts.length - 10} more unique values`); } // Show unique dates const uniqueDates = [...new Set(jsonData.map(item => item.usage_date))]; console.log('\nUnique usage_date values:'); uniqueDates.slice(0, 10).forEach((date, i) => { console.log(` ${i + 1}. ${date}`); }); // Show unique accounts const uniqueAccounts = [...new Set(jsonData.map(item => item.account_id).filter(Boolean))]; if (uniqueAccounts.length > 0) { console.log('\nUnique account_id values:'); uniqueAccounts.slice(0, 10).forEach((acc, i) => { console.log(` ${i + 1}. ${acc}`); }); } // Save full response for inspection fs.writeFileSync('api-response-sample.json', JSON.stringify(jsonData, null, 2)); console.log('\n✓ Full response saved to api-response-sample.json'); return; } else { console.log('No JSON found in response. Raw text:'); console.log(text.substring(0, 500)); } } } catch (e) { // Continue to next line } } } console.log('Could not extract data from API response'); } catch (error) { console.error('Error fetching data:', error.message); if (error.response) { console.error('Response status:', error.response.status); console.error('Response data:', error.response.data?.substring?.(0, 200)); } } } fetchAndShowValues();

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