UNPKG

eventpulse-mcp

Version:

EventPulse MCP Server - Hyper-local event-driven marketing campaigns for small businesses

98 lines (86 loc) โ€ข 2.97 kB
// Simple test script for EventPulse MCP API const axios = require('axios'); const BASE_URL = process.env.API_URL || 'http://localhost:3000'; // Test data const testRequests = [ { name: 'Diwali Sweet Shop (Hindi)', data: { business_type: 'sweet shop', event: 'diwali', language: 'hindi', location: 'Mumbai', goal: 'increase sales' } }, { name: 'Navratri Clothing Store (Gujarati)', data: { business_type: 'clothing store', event: 'navratri', language: 'gujarati', location: 'Ahmedabad', goal: 'brand awareness' } }, { name: 'Eid Restaurant (English)', data: { business_type: 'restaurant', event: 'eid', language: 'english', location: 'Delhi', goal: 'customer engagement' } } ]; async function runTests() { console.log('๐Ÿงช Starting EventPulse MCP API Tests\n'); // Test health endpoint try { console.log('๐Ÿ“‹ Testing health endpoint...'); const healthResponse = await axios.get(`${BASE_URL}/`); console.log('โœ… Health check passed:', healthResponse.data.name); } catch (error) { console.error('โŒ Health check failed:', error.message); return; } // Test campaign generation for (const test of testRequests) { console.log(`\n๐ŸŽฏ Testing: ${test.name}`); console.log('Request:', JSON.stringify(test.data, null, 2)); try { const startTime = Date.now(); const response = await axios.post(`${BASE_URL}/v1/generate-campaign`, test.data); const endTime = Date.now(); console.log('โœ… Campaign generated successfully'); console.log(`โฑ๏ธ Processing time: ${endTime - startTime}ms`); console.log('๐Ÿ“ WhatsApp Message:', response.data.campaign_content.whatsapp_message); console.log('๐Ÿ“ฑ Social Posts:', response.data.campaign_content.social_media_posts.length, 'posts'); console.log('๐Ÿท๏ธ Hashtags:', response.data.campaign_content.hashtags.join(', ')); console.log('๐ŸŽ Offers:', response.data.campaign_content.promotional_offers.length, 'offers'); } catch (error) { console.error('โŒ Test failed:', error.response?.data || error.message); } } // Test error handling console.log('\n๐Ÿšจ Testing error handling...'); try { await axios.post(`${BASE_URL}/v1/generate-campaign`, { business_type: 'invalid', // Missing required fields }); } catch (error) { if (error.response?.status === 400) { console.log('โœ… Error handling works correctly'); } else { console.error('โŒ Unexpected error response:', error.response?.status); } } console.log('\n๐ŸŽ‰ Tests completed!'); } // Run tests if this file is executed directly if (require.main === module) { runTests().catch(console.error); } module.exports = { runTests };