/**
* Simple validation test for the MCP server
*
* This script can be run to verify the server starts correctly.
* It doesn't test the full functionality (which requires VSCode)
* but validates the basic structure and imports.
*
* Run with: npx tsx scripts/validate.ts
*
* @author Sukarth Acharya
* @license MIT
*/
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
async function validate(): Promise<void> {
console.log('Validating vscode-automation-mcp...\n');
// Test 1: Import all tool modules
console.log('1. Testing module imports...');
try {
const commands = await import('../src/tools/commands.js');
const uiActions = await import('../src/tools/ui-actions.js');
const inspection = await import('../src/tools/inspection.js');
const testing = await import('../src/tools/testing.js');
const driver = await import('../src/vscode-driver.js');
console.log(' ✓ All modules imported successfully\n');
} catch (error) {
console.error(' ✗ Module import failed:', error);
process.exit(1);
}
// Test 2: Create MCP server instance
console.log('2. Testing MCP server creation...');
try {
const server = new McpServer({
name: 'test-server',
version: '1.0.0',
});
console.log(' ✓ MCP server created successfully\n');
} catch (error) {
console.error(' ✗ MCP server creation failed:', error);
process.exit(1);
}
// Test 3: Validate tool schemas
console.log('3. Testing tool schemas...');
try {
const { z } = await import('zod');
const { executeCommandInputSchema } = await import('../src/tools/commands.js');
const { clickElementInputSchema } = await import('../src/tools/ui-actions.js');
const { takeScreenshotInputSchema } = await import('../src/tools/inspection.js');
const { getEditorContentInputSchema } = await import('../src/tools/testing.js');
// Validate schemas are Zod objects
if (executeCommandInputSchema.commandId instanceof z.ZodType) {
console.log(' ✓ Command schemas valid');
}
if (clickElementInputSchema.selector instanceof z.ZodType) {
console.log(' ✓ UI action schemas valid');
}
if (takeScreenshotInputSchema.filename instanceof z.ZodType) {
console.log(' ✓ Inspection schemas valid');
}
console.log(' ✓ All schemas validated successfully\n');
} catch (error) {
console.error(' ✗ Schema validation failed:', error);
process.exit(1);
}
// Test 4: Validate driver singleton
console.log('4. Testing VSCode driver...');
try {
const { getVSCodeDriver, VSCodeDriver } = await import('../src/vscode-driver.js');
const driver = getVSCodeDriver();
if (driver.getState() === 'idle') {
console.log(' ✓ Driver initialized in idle state');
}
VSCodeDriver.resetInstance();
console.log(' ✓ Driver reset successfully\n');
} catch (error) {
console.error(' ✗ Driver test failed:', error);
process.exit(1);
}
console.log('✓ All validation tests passed!\n');
console.log('Note: Full functionality testing requires a running VSCode instance.');
console.log('The server is ready to be used with an MCP client.\n');
}
validate().catch((error) => {
console.error('Validation failed:', error);
process.exit(1);
});