#!/usr/bin/env node /** * Basic test to verify the MCP server can initialize */ import { ConfigManager } from './src/config/ConfigManager.js'; import { ToolGenerator } from './src/tools/ToolGenerator.js'; import { PUBLIC_ENDPOINTS } from './src/config/endpoints.js'; async function runBasicTest() { console.log('๐Ÿงช Basic Laravel Healthcare MCP Server Test\n'); try { // Test 1: Environment setup console.log('1. Testing environment setup...'); process.env.LARAVEL_API_BASE_URL = 'https://example.com'; console.log('โœ… Environment variables set'); // Test 2: Configuration loading console.log('2. Testing configuration loading...'); const config = new ConfigManager(); console.log('โœ… Configuration loaded successfully'); console.log(` Base URL: ${config.get('LARAVEL_API_BASE_URL')}`); console.log(` Server Name: ${config.get('MCP_SERVER_NAME')}`); // Test 3: Endpoint registry console.log('3. Testing endpoint registry...'); console.log(`โœ… ${PUBLIC_ENDPOINTS.length} public endpoints loaded`); // Test 4: Tool generation console.log('4. Testing tool generation...'); // Create a mock API client for testing const mockApiClient = { get: () => Promise.resolve({}), post: () => Promise.resolve({}), put: () => Promise.resolve({}), delete: () => Promise.resolve({}), patch: () => Promise.resolve({}) }; const toolGenerator = new ToolGenerator(mockApiClient); const tools = toolGenerator.generateAllTools(); console.log(`โœ… ${tools.length} MCP tools generated`); // Test 5: Tool structure validation console.log('5. Testing tool structure...'); if (tools.length > 0) { const firstTool = tools[0]; const requiredFields = ['name', 'description', 'inputSchema']; const hasAllFields = requiredFields.every(field => firstTool[field]); if (hasAllFields) { console.log('โœ… Tool structure is valid'); console.log(` Sample tool: ${firstTool.name}`); } else { throw new Error('Tool structure is invalid'); } } // Test 6: Configuration summary console.log('6. Configuration summary...'); const summary = config.getSummary(); console.log(`โœ… Server: ${summary.serverName} v${summary.serverVersion}`); console.log(` API URL: ${summary.apiBaseUrl}`); console.log(` Environment: ${summary.environment}`); console.log(` Auth Types: ${summary.authTypesConfigured.length} configured`); console.log('\n๐ŸŽ‰ All basic tests passed!'); console.log('\n๐Ÿ“‹ Summary:'); console.log(` โ€ข Configuration: โœ… Loaded`); console.log(` โ€ข Endpoints: โœ… ${PUBLIC_ENDPOINTS.length} public endpoints`); console.log(` โ€ข Tools: โœ… ${tools.length} MCP tools generated`); console.log(` โ€ข Structure: โœ… Valid`); console.log('\n๐Ÿš€ The MCP server is ready to be configured and started!'); console.log('\nNext steps:'); console.log('1. Copy .env.example to .env'); console.log('2. Configure LARAVEL_API_BASE_URL and authentication credentials'); console.log('3. Run: npm start'); } catch (error) { console.error('\nโŒ Test failed:', error.message); console.error('Stack trace:', error.stack); process.exit(1); } } runBasicTest();