first
This commit is contained in:
89
test-basic.js
Normal file
89
test-basic.js
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/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();
|
Reference in New Issue
Block a user