Skip to main content
Glama
test-mcp-direct.cjs7.42 kB
#!/usr/bin/env node const https = require('https'); const axios = require('axios'); const axiosInstance = axios.create({ httpsAgent: new https.Agent({ rejectUnauthorized: false }), timeout: 30000 }); async function testMcpDirect() { console.log('\n════════════════════════════════════════════════════════════'); console.log(' TESTING MCP DIRECTLY (LIKE CLAUDE DESKTOP)'); console.log('════════════════════════════════════════════════════════════\n'); const mcpUrl = 'https://injuries-opposite-mine-pmid.trycloudflare.com/mcp'; try { // First, we need to get an OAuth token // This simulates what Claude Desktop does console.log('📋 Simulating Claude Desktop MCP call...\n'); // Get the bearer token from the current session // For testing, we'll use the token from the OAuth flow const token = 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkYXZpZCthbGxjbG91ZEB1bWJyZWxsYWNvc3QuY29tIiwiY2xpZW50SWQiOiJjbGF1ZGUtbWNwLWNsaWVudC1kY2RmZjFkNjRiMDE0Yzg5IiwiaWF0IjoxNzU4NDYyNDcxLCJleHAiOjE3NTg1NDg4NzF9.VpM9r79r0VJOqPRgIiuJUkEOzIAzRTqS1K-6ZlrnQJGnHn42Q7ItBJNzKxWtMXFx-nSKMaKxSXJOt8H6Z0Z1PJFl4dOzjKJjHwuXRbAy0L5xHQbOxIBz7P3XiFQnHjDJ1VvVRFbjOkJK6HnsOD0u6ACbmKZCNRaxKPmK60qzUzFbiCRNQPgK8FnwSzP34x98IUEgU_-EE16XZWCZoABLYHovS8BgXQkzAQJLdvOkXzWRxBqAQLRXyeBHQ1-K3VQ'; // Test 1: Bank Leumi with groupBy none (recent 3 months) console.log('🔍 Test 1: Bank Leumi costs for last 3 months (groupBy: none)'); const request1 = { method: 'tools/call', params: { name: 'api__invoices_caui', arguments: { endDate: '2025-09-21', groupBy: 'none', costType: '["cost", "discount"]', accountId: '696314371547', startDate: '2025-07-01', userQuery: 'Show me Bank Leumi costs for last 3 months with no grouping', isUnblended: 'true', periodGranLevel: 'month', customer_account_key: '22676', customer_division_id: '139' } }, jsonrpc: '2.0', id: 1 }; console.log('Request:', JSON.stringify(request1.params.arguments, null, 2)); const response1 = await axiosInstance.post(mcpUrl, request1, { headers: { 'Content-Type': 'application/json', 'Authorization': token, 'User-Agent': 'Claude-User', 'Accept': 'application/json, text/event-stream' } }); console.log('\n📊 MCP Response:'); if (response1.data && response1.data.result && response1.data.result.content) { const content = response1.data.result.content[0]; if (content && content.text) { // Parse the markdown response const text = content.text; const jsonMatch = text.match(/```json\n([\s\S]*?)\n```/); if (jsonMatch) { const jsonData = JSON.parse(jsonMatch[1]); console.log('Parsed JSON data:'); jsonData.forEach(item => { console.log(` ${item.usage_date}: Account ${item.account_id}, Cost: $${item.total_cost.toFixed(2)}`); }); // Check if this is the wrong account if (jsonData[0] && jsonData[0].account_id === '268413799883') { console.log('\n❌ ERROR: Returning wrong account!'); console.log(' Requested: 696314371547 (Bank Leumi)'); console.log(' Received: 268413799883 (Unknown)'); } } else { console.log('Full response text:', text); } } } else { console.log('Full response:', JSON.stringify(response1.data, null, 2)); } // Test 2: Same query but for August only console.log('\n\n🔍 Test 2: Bank Leumi costs for August 2025 only'); const request2 = { method: 'tools/call', params: { name: 'api__invoices_caui', arguments: { endDate: '2025-08-31', groupBy: 'none', costType: '["cost", "discount"]', startDate: '2025-08-01', userQuery: 'Show me Bank Leumi costs for August 2025', isUnblended: 'true', periodGranLevel: 'month', customer_account_key: '22676', customer_division_id: '139' } }, jsonrpc: '2.0', id: 2 }; console.log('Request:', JSON.stringify(request2.params.arguments, null, 2)); const response2 = await axiosInstance.post(mcpUrl, request2, { headers: { 'Content-Type': 'application/json', 'Authorization': token, 'User-Agent': 'Claude-User', 'Accept': 'application/json, text/event-stream' } }); console.log('\n📊 MCP Response:'); if (response2.data && response2.data.result && response2.data.result.content) { const content = response2.data.result.content[0]; if (content && content.text) { const text = content.text; const jsonMatch = text.match(/```json\n([\s\S]*?)\n```/); if (jsonMatch) { const jsonData = JSON.parse(jsonMatch[1]); console.log('Parsed JSON data:'); jsonData.forEach(item => { console.log(` ${item.usage_date}: Account ${item.account_id}, Cost: $${item.total_cost.toFixed(6)}`); }); console.log('\n📝 Expected from MANUAL_ANSWERS.txt:'); console.log(' 2025-08: Account 696314371547, Cost: $0.002684'); if (jsonData[0]) { const match = jsonData[0].account_id === '696314371547' && Math.abs(jsonData[0].total_cost - 0.002684) < 0.0001; console.log(`\n${match ? '✅' : '❌'} Comparison result`); } } } } } catch (error) { console.error('\n❌ Error:', error.message); if (error.response) { console.error('Response status:', error.response.status); if (error.response.status === 401) { console.error('⚠️ Authorization failed. The token may have expired.'); console.error(' Please get a fresh token from the OAuth flow.'); } console.error('Response data:', error.response.data); } } } testMcpDirect().catch(console.error);

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