Skip to main content
Glama
desktop-simulator-daily-costs.cjsβ€’7.92 kB
#!/usr/bin/env node const { spawn } = require('child_process'); const path = require('path'); console.log('πŸ–₯️ CLAUDE DESKTOP SIMULATOR'); console.log('Question: "what is the daily cost from august 21th till august 24"'); console.log('Account: david+saola@umbrellacost.com'); console.log('Simulating how Claude Desktop would handle this natural language query'); console.log('════════════════════════════════════════════════\n'); // Start the MCP server const serverPath = path.join(__dirname, 'src', 'index.ts'); const server = spawn('npx', ['tsx', serverPath], { env: { ...process.env }, stdio: ['pipe', 'pipe', 'pipe'] }); let serverReady = false; let authenticatedSuccess = false; server.stderr.on('data', (data) => { const output = data.toString(); if (output.includes('started successfully')) { console.log('πŸš€ MCP Server: Started successfully'); } if (output.includes('Umbrella MCP Server started successfully')) { serverReady = true; simulateDesktopAuthentication(); } }); server.stdout.on('data', (data) => { const text = data.toString(); const lines = text.split('\n'); for (const line of lines) { if (line.trim() && line.includes('"result"')) { try { const response = JSON.parse(line); // Handle authentication response if (response.id === 1 && text.includes('Successfully authenticated')) { console.log('βœ… Desktop Simulator: Authentication successful\n'); authenticatedSuccess = true; setTimeout(() => simulateDesktopNaturalLanguageQuery(), 2000); } // Handle daily costs response else if (response.id === 2 && authenticatedSuccess) { console.log('πŸ“Š DESKTOP CLIENT SIMULATION - DAILY COSTS RESPONSE:'); console.log('═'.repeat(80)); const content = response.result?.content?.find(c => c.type === 'text')?.text || 'No content'; // Simulate how desktop client would process and display this console.log('πŸ€– RAW MCP RESPONSE:'); console.log(content); console.log('\n' + '═'.repeat(80)); // Simulate desktop client parsing and formatting console.log('πŸ–₯️ DESKTOP CLIENT FORMATTED RESPONSE:'); console.log(formatForDesktop(content)); console.log('\n' + '═'.repeat(80)); // Desktop client analysis console.log('πŸ” DESKTOP CLIENT ANALYSIS:'); analyzeDesktopResponse(content); server.kill(); process.exit(0); } } catch (e) { // Continue if not valid JSON } } } }); function simulateDesktopAuthentication() { console.log('πŸ” Desktop Simulator: Authenticating with saola account...\n'); const authRequest = { jsonrpc: '2.0', method: 'tools/call', params: { name: 'authenticate_user', arguments: { username: 'david+saola@umbrellacost.com', password: 'Dsamsung1!' } }, id: 1 }; server.stdin.write(JSON.stringify(authRequest) + '\n'); } function simulateDesktopNaturalLanguageQuery() { console.log('πŸ’¬ Desktop Simulator: Processing natural language query...'); console.log('🧠 Desktop AI Thinking: "User wants daily costs from Aug 21-24, 2025"'); console.log('πŸ”§ Desktop AI Decision: Use invoices/caui endpoint with daily granularity'); console.log('πŸ“… Desktop AI Date Processing: 2025-08-21 to 2025-08-24'); console.log('🏒 Desktop AI Account Selection: Using primary account 932213950603\n'); // Simulate how desktop Claude would interpret the natural language // "what is the daily cost from august 21th till august 24" // -> startDate: 2025-08-21, endDate: 2025-08-24, periodGranLevel: day const dailyCostRequest = { jsonrpc: '2.0', method: 'tools/call', params: { name: 'api___invoices_caui', arguments: { accountId: '932213950603', startDate: '2025-08-21', endDate: '2025-08-24', groupBy: 'none', periodGranLevel: 'day' // Desktop client correctly identifies need for daily granularity } }, id: 2 }; console.log('πŸ“€ Desktop Simulator: Sending MCP request...'); console.log(' Tool: api___invoices_caui'); console.log(' Args:', JSON.stringify(dailyCostRequest.params.arguments, null, 2)); console.log(); server.stdin.write(JSON.stringify(dailyCostRequest) + '\n'); } function formatForDesktop(mcpResponse) { try { // Simulate desktop client formatting the response for user display let formatted = 'πŸ“Š **Daily Cost Breakdown: August 21-24, 2025**\n\n'; // Check if response contains JSON data const jsonMatch = mcpResponse.match(/```json\n([\s\S]*?)\n```/); if (jsonMatch) { const data = JSON.parse(jsonMatch[1]); if (Array.isArray(data) && data.length > 0) { let totalCost = 0; formatted += '**Daily Costs:**\n'; data.forEach(item => { const date = item.usage_date || 'Unknown Date'; const cost = parseFloat(item.total_cost || 0); totalCost += cost; formatted += `β€’ ${date}: $${cost.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2})}\n`; }); formatted += `\n**Total for Period:** $${totalCost.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2})}`; formatted += `\n**Account:** 932213950603`; formatted += `\n**Period:** August 21-24, 2025`; } else { formatted += 'βšͺ No cost data found for the specified period.'; } } else { formatted += '❌ Unable to parse cost data from response.'; } return formatted; } catch (error) { return `❌ Desktop formatting error: ${error.message}`; } } function analyzeDesktopResponse(mcpResponse) { console.log('User Question: "what is the daily cost from august 21th till august 24"'); console.log(`Response Length: ${mcpResponse.length} characters`); console.log(`Contains JSON: ${mcpResponse.includes('```json') ? 'Yes' : 'No'}`); console.log(`Contains Success Status: ${mcpResponse.includes('βœ… Success') ? 'Yes' : 'No'}`); console.log(`Contains Error: ${mcpResponse.includes('❌') || mcpResponse.includes('Error') ? 'Yes' : 'No'}`); console.log(`Contains Daily Data: ${mcpResponse.includes('"usage_date"') ? 'Yes' : 'No'}`); console.log(`Contains Cost Amounts: ${mcpResponse.includes('"total_cost"') ? 'Yes' : 'No'}`); // Check for specific daily dates const hasDailyGranularity = mcpResponse.includes('2025-08-21') || mcpResponse.includes('2025-08-22') || mcpResponse.includes('2025-08-23') || mcpResponse.includes('2025-08-24'); console.log(`Shows Daily Granularity: ${hasDailyGranularity ? 'Yes' : 'No'}`); // Desktop client satisfaction assessment let satisfaction = 'Good'; if (mcpResponse.includes('❌') || mcpResponse.includes('Error')) { satisfaction = 'Poor - Has Errors'; } else if (!mcpResponse.includes('total_cost')) { satisfaction = 'Fair - No Cost Data'; } else if (!hasDailyGranularity) { satisfaction = 'Fair - Wrong Granularity'; } console.log(`Desktop User Satisfaction: ${satisfaction}`); if (satisfaction === 'Good') { console.log('βœ… Desktop Client Analysis: This response would satisfy the user'); } else { console.log('⚠️ Desktop Client Analysis: User might need follow-up questions'); } } // Give server 20 seconds to start setTimeout(() => { if (!serverReady) { console.error('❌ MCP Server failed to start within 20 seconds'); server.kill(); process.exit(1); } }, 20000); console.log('πŸš€ Starting Claude Desktop Simulation...');

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