UNPKG

@economic-mcp/server-economic

Version:

Model Context Protocol server for e-conomic API

57 lines (49 loc) 1.94 kB
const axios = require('axios'); // Create a test file to verify our server is working correctly async function testServer() { try { console.log('Testing MCP e-conomic server...'); // Test health endpoint console.log('\n1. Testing health endpoint:'); const healthResponse = await axios.get('http://localhost:3000/health'); console.log('Health check response:', healthResponse.data); // Test invoices endpoint (will fail with demo credentials but we can verify error handling) console.log('\n2. Testing invoices endpoint:'); try { const invoicesResponse = await axios.get('http://localhost:3000/invoices', { headers: { 'X-AppSecretToken': 'demo', 'X-AgreementGrantToken': 'demo' } }); console.log('Invoices response:', invoicesResponse.data); } catch (error) { console.log('Expected error from invoices endpoint (using demo credentials):', error.response?.status, error.response?.data?.error || error.message); } // Test journals endpoint (will fail with demo credentials but we can verify error handling) console.log('\n3. Testing journals endpoint:'); try { const journalsResponse = await axios.get('http://localhost:3000/journals', { headers: { 'X-AppSecretToken': 'demo', 'X-AgreementGrantToken': 'demo' } }); console.log('Journals response:', journalsResponse.data); } catch (error) { console.log('Expected error from journals endpoint (using demo credentials):', error.response?.status, error.response?.data?.error || error.message); } console.log('\nTest completed. Server is functioning as expected.'); } catch (error) { console.error('Test failed:', error.message); } } // Only run if executed directly if (require.main === module) { testServer(); } module.exports = testServer;