Skip to main content
Glama
detailed-mcp-test.cjsโ€ข9.06 kB
#!/usr/bin/env node // Detailed MCP Protocol Test - Shows exact Claude Desktop responses const { spawn } = require('child_process'); const { EventEmitter } = require('events'); class DetailedMCPTest extends EventEmitter { constructor() { super(); this.serverProcess = null; this.messageId = 1; this.pendingRequests = new Map(); } async startServer() { console.log('๐Ÿ”Œ Starting MCP server...'); this.serverProcess = spawn('node', ['dist/index.js'], { stdio: ['pipe', 'pipe', 'pipe'] }); this.serverProcess.stdout.on('data', (data) => { const lines = data.toString().split('\n').filter(line => line.trim()); lines.forEach(line => { try { const message = JSON.parse(line); this.handleMessage(message); } catch (e) { // Ignore non-JSON lines } }); }); this.serverProcess.stderr.on('data', (data) => { // Suppress server logs for cleaner output }); await new Promise(resolve => setTimeout(resolve, 2000)); console.log('โœ… MCP server ready'); } handleMessage(message) { if (message.id && this.pendingRequests.has(message.id)) { const resolve = this.pendingRequests.get(message.id); this.pendingRequests.delete(message.id); resolve(message); } } async sendRequest(method, params) { const id = this.messageId++; const request = { jsonrpc: '2.0', id, method, params }; return new Promise((resolve, reject) => { this.pendingRequests.set(id, resolve); this.serverProcess.stdin.write(JSON.stringify(request) + '\n'); setTimeout(() => { if (this.pendingRequests.has(id)) { this.pendingRequests.delete(id); reject(new Error('Request timeout')); } }, 30000); }); } async initialize() { await this.sendRequest('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'claude-desktop-test', version: '1.0.0' } }); } async authenticate() { console.log('\n๐Ÿ” Authenticating david+saola@umbrellacost.com...'); const authResult = await this.sendRequest('tools/call', { name: 'authenticate_user', arguments: { username: 'david+saola@umbrellacost.com', password: 'Dsamsung1!' } }); const authResponse = authResult.result.content[0].text; console.log('โœ…', authResponse.split('\n')[0]); return authResponse.includes('Successfully authenticated'); } async testQuestion(questionNum, questionText, toolName, args) { console.log('\n' + 'โ•'.repeat(80)); console.log(`๐Ÿ“ QUESTION ${questionNum}: "${questionText}"`); console.log('โ•'.repeat(80)); try { const result = await this.sendRequest('tools/call', { name: toolName, arguments: args }); const response = result.result.content[0].text; console.log('\n๐Ÿค– CLAUDE DESKTOP RECEIVES:'); console.log('โ”€'.repeat(50)); // Show first 1000 characters of response to keep it readable if (response.length > 1000) { console.log(response.substring(0, 1000) + '\n... [response truncated for readability]'); } else { console.log(response); } // Extract key metrics for cost questions if (toolName === 'api___invoices_caui') { const costMatch = response.match(/Total.*?\$([0-9,]+\.?[0-9]*)/i); const periodMatch = response.match(/Period: ([^\n]+)/); const accountMatch = response.match(/Account: ([^\n]+)/); console.log('\n๐Ÿ“Š KEY METRICS:'); console.log(` Period: ${periodMatch ? periodMatch[1] : 'Not specified'}`); console.log(` Account: ${accountMatch ? accountMatch[1] : 'Multi-account'}`); console.log(` Total Cost: ${costMatch ? '$' + costMatch[1] : 'Not displayed in summary'}`); } // Extract key info for recommendations if (toolName === 'api___recommendations_report') { const totalSavings = response.match(/Total.*?\$([0-9,]+)/i); const rightSizing = response.match(/Right Sizing.*?\$([0-9,]+)/i); const categories = (response.match(/Category: ([^\n]+)/g) || []).length; console.log('\n๐Ÿ’ก RECOMMENDATIONS SUMMARY:'); console.log(` Total Savings: ${totalSavings ? '$' + totalSavings[1] : 'Not specified'}`); console.log(` Right Sizing: ${rightSizing ? '$' + rightSizing[1] : 'Not specified'}`); console.log(` Categories: ${categories} recommendation types`); } // Extract account info if (toolName === 'api___users') { const accountMatches = response.match(/Account \d+:/g) || []; const cloudTypes = [...new Set((response.match(/Cloud Type: ([^\n]+)/g) || []).map(m => m.replace('Cloud Type: ', '')))]; console.log('\n๐Ÿข ACCOUNT SUMMARY:'); console.log(` Total Accounts: ${accountMatches.length}`); console.log(` Cloud Providers: ${cloudTypes.join(', ')}`); } console.log('\nโœ… SUCCESS - Response received and processed'); } catch (error) { console.log('\nโŒ FAILED:', error.message); } } async disconnect() { if (this.serverProcess) { this.serverProcess.kill(); console.log('\n๐Ÿ”Œ Disconnected from MCP server'); } } } async function runDetailedTest() { console.log('๐Ÿ”ฌ DETAILED MCP PROTOCOL TEST'); console.log('Shows exactly what Claude Desktop receives for each question'); console.log('โ•'.repeat(80)); const client = new DetailedMCPTest(); try { await client.startServer(); await client.initialize(); const authenticated = await client.authenticate(); if (!authenticated) { console.log('โŒ Authentication failed'); return; } // Test all questions from questions.test file const questions = [ { question: "show me the list of customers", tool: "api___msp_customers", args: {} }, { question: "what is my total cost?", tool: "api___invoices_caui", args: { startDate: "2025-08-11", endDate: "2025-08-17", groupBy: "none", periodGranLevel: "day", costType: ["cost", "discount"], isUnblended: true } }, { question: "what is my total AWS cost?", tool: "api___invoices_caui", args: { startDate: "2025-08-11", endDate: "2025-08-17", groupBy: "none", periodGranLevel: "day", costType: ["cost", "discount"], isUnblended: true, cloud_context: "aws" } }, { question: "what is my total GCP cost?", tool: "api___invoices_caui", args: { startDate: "2025-08-11", endDate: "2025-08-17", groupBy: "none", periodGranLevel: "day", costType: ["cost", "discount"], isUnblended: true, cloud_context: "gcp" } }, { question: "what is my total Azure cost?", tool: "api___invoices_caui", args: { startDate: "2025-08-11", endDate: "2025-08-17", groupBy: "none", periodGranLevel: "day", costType: ["cost", "discount"], isUnblended: true, cloud_context: "azure" } }, { question: "show me the total cost per month", tool: "api___invoices_caui", args: { startDate: "2025-02-01", endDate: "2025-08-17", groupBy: "none", periodGranLevel: "month", costType: ["cost", "discount"], isUnblended: true } }, { question: "show me all available accounts", tool: "api___users", args: {} }, { question: "what do you recommend to do for saving AWS costs?", tool: "api___recommendations_report", args: {} }, { question: "what are the potential savings per category?", tool: "api___recommendations_report", args: {} }, { question: "Is there any anomalies on AWS?", tool: "api___anomaly_detection", args: { startDate: "2025-08-11", endDate: "2025-08-17" } } ]; for (let i = 0; i < questions.length; i++) { const q = questions[i]; await client.testQuestion(i + 1, q.question, q.tool, q.args); } console.log('\n' + '๐ŸŽ‰'.repeat(40)); console.log('๐Ÿ ALL QUESTIONS TESTED'); console.log('This is exactly what Claude Desktop will receive!'); console.log('๐ŸŽ‰'.repeat(40)); } catch (error) { console.error('โŒ Test failed:', error.message); } finally { await client.disconnect(); } } runDetailedTest();

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