#!/usr/bin/env npx tsx import type { MCPServerConfig } from '../src/main/services/mcp-service'; /** * Test script to verify MCP server configuration display */ function testConfigDisplay() { console.log('šŸ”§ Testing MCP Server Configuration Display\n'); function getConfigSummary(server: MCPServerConfig): string { switch (server.type) { case 'filesystem': if (server.config.type === 'filesystem') { return server.config.rootPath || 'No path configured'; } return 'No path configured'; case 'github': if (server.config.type === 'github') { return server.config.owner && server.config.repo ? `${server.config.owner}/${server.config.repo}` : 'No repository configured'; } return 'No repository configured'; case 'postgres': if (server.config.type === 'postgres') { return server.config.host && server.config.database ? `${server.config.host}/${server.config.database}` : 'No database configured'; } return 'No database configured'; case 'sqlite': if (server.config.type === 'sqlite') { return server.config.path || 'No database path configured'; } return 'No database path configured'; case 'custom': if (server.config.type === 'custom') { const command = server.config.command || 'No command configured'; const args = server.config.args; if (args && args.length > 0) { return `${command} ${args.join(' ')}`; } return command; } return 'No command configured'; default: return 'Configuration not set'; } } const testServers: MCPServerConfig[] = [ { id: 'registry-1756139416766', name: 'Wikipedia', type: 'custom', status: 'connected', enabled: true, config: { type: 'custom', command: 'npx', args: ['-y', 'wikipedia-mcp'], env: {} }, createdAt: '2025-08-25T02:03:36.766Z', updatedAt: '2025-08-25T02:03:36.766Z' }, { id: 'registry-1756306451137', name: 'QR Codes', type: 'custom', status: 'connected', enabled: true, config: { type: 'custom', command: 'npx', args: ['-y', 'qr-codes-mcp'], env: {} }, createdAt: '2025-08-27T00:34:11.137Z', updatedAt: '2025-08-27T00:34:11.137Z' }, { id: 'test-package', name: 'Test Package Direct', type: 'custom', status: 'disconnected', enabled: true, config: { type: 'custom', command: '@modelcontextprotocol/server-filesystem', args: ['/path/to/dir'], env: {} }, createdAt: '2025-08-27T00:00:00.000Z', updatedAt: '2025-08-27T00:00:00.000Z' }, { id: 'test-executable', name: 'Test Executable', type: 'custom', status: 'disconnected', enabled: true, config: { type: 'custom', command: '/usr/local/bin/my-server', args: ['--port', '3000'], env: {} }, createdAt: '2025-08-27T00:00:00.000Z', updatedAt: '2025-08-27T00:00:00.000Z' }, { id: 'filesystem-test', name: 'Filesystem Test', type: 'filesystem', status: 'connected', enabled: true, config: { type: 'filesystem', rootPath: '/Users/test/documents', readOnly: false }, createdAt: '2025-08-27T00:00:00.000Z', updatedAt: '2025-08-27T00:00:00.000Z' } ]; console.log('šŸ“‹ Testing Configuration Display:\n'); for (const server of testServers) { const summary = getConfigSummary(server); console.log(`šŸ“Œ ${server.name} (${server.type})`); console.log(` Raw Config: ${JSON.stringify(server.config)}`); console.log(` Display: "${summary}"`); if (server.type === 'custom' && summary === 'npx') { console.log(` āŒ BUG: Would display as "Configurationnpx" (missing args)`); } else if (server.type === 'custom' && summary.startsWith('npx ')) { console.log(` āœ… Fixed: Displays full command with args`); } console.log(''); } console.log('šŸ–„ļø UI Display Preview:\n'); console.log('ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”'); for (const server of testServers.slice(0, 3)) { const summary = getConfigSummary(server); console.log(`│ Configuration │`); console.log(`│ ${summary.padEnd(44)} │`); console.log('ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤'); } console.log('ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜'); console.log('\nāœ… Configuration display test completed!'); } testConfigDisplay();