Skip to main content
Glama
ooples

MCP Console Automation Server

test-smart-executor-profile.tsβ€’5.24 kB
import { ConsoleManager } from './core/ConsoleManager.js'; import { SmartExecutor } from './core/SmartExecutor.js'; async function testSmartExecutorWithProfile() { console.log('πŸ§ͺ Testing Smart Executor with Saved Profile...\n'); const consoleManager = new ConsoleManager({ sessionManager: { maxSessions: 10, sessionTimeout: 300000 } }); const smartExecutor = new SmartExecutor(consoleManager); try { console.log('Creating session using saved profile "github-runner-server"...'); const sessionId = await consoleManager.createSession({ command: 'ssh', args: [], consoleType: 'ssh', sshOptions: { host: 'ns107444.ip-51-81-109.us', username: 'ubuntu', password: '0hbTMtqW0D4oH0fv', port: 22 } }); console.log(`βœ“ Session created: ${sessionId}\n`); console.log('═'.repeat(60)); console.log('Test 1: Quick Echo Command (should use FAST strategy)'); console.log('═'.repeat(60)); const start1 = Date.now(); const result1 = await smartExecutor.execute('echo "Hello from Smart Executor"', { sessionId, timeout: 10000 }); const duration1 = Date.now() - start1; console.log(`Strategy Used: ${result1.strategyUsed}`); console.log(`Switched: ${result1.switched}`); console.log(`Duration: ${duration1}ms`); console.log(`Exit Code: ${result1.exitCode}`); console.log(`Output: ${result1.output.substring(0, 100).trim()}`); console.log(`Success: ${result1.success ? 'βœ“' : 'βœ—'}\n`); console.log('═'.repeat(60)); console.log('Test 2: System Info Commands (should use FAST strategy)'); console.log('═'.repeat(60)); const start2 = Date.now(); const result2 = await smartExecutor.execute('pwd && whoami && hostname', { sessionId, timeout: 10000 }); const duration2 = Date.now() - start2; console.log(`Strategy Used: ${result2.strategyUsed}`); console.log(`Switched: ${result2.switched}`); console.log(`Duration: ${duration2}ms`); console.log(`Exit Code: ${result2.exitCode}`); console.log(`Output: ${result2.output.trim()}`); console.log(`Success: ${result2.success ? 'βœ“' : 'βœ—'}\n`); console.log('═'.repeat(60)); console.log('Test 3: File Listing (should use FAST strategy)'); console.log('═'.repeat(60)); const start3 = Date.now(); const result3 = await smartExecutor.execute('ls -lh /home/ubuntu', { sessionId, timeout: 10000 }); const duration3 = Date.now() - start3; console.log(`Strategy Used: ${result3.strategyUsed}`); console.log(`Switched: ${result3.switched}`); console.log(`Duration: ${duration3}ms`); console.log(`Exit Code: ${result3.exitCode}`); console.log(`Output (first 300 chars):\n${result3.output.substring(0, 300).trim()}`); console.log(`Success: ${result3.success ? 'βœ“' : 'βœ—'}\n`); console.log('═'.repeat(60)); console.log('Test 4: Disk Usage (should use FAST strategy)'); console.log('═'.repeat(60)); const start4 = Date.now(); const result4 = await smartExecutor.execute('df -h', { sessionId, timeout: 10000 }); const duration4 = Date.now() - start4; console.log(`Strategy Used: ${result4.strategyUsed}`); console.log(`Switched: ${result4.switched}`); console.log(`Duration: ${duration4}ms`); console.log(`Exit Code: ${result4.exitCode}`); console.log(`Output (first 300 chars):\n${result4.output.substring(0, 300).trim()}`); console.log(`Success: ${result4.success ? 'βœ“' : 'βœ—'}\n`); console.log('═'.repeat(60)); console.log('Test 5: Sequential Commands'); console.log('═'.repeat(60)); const start5 = Date.now(); const result5a = await smartExecutor.execute('echo "Command 1"', { sessionId, timeout: 10000 }); const result5b = await smartExecutor.execute('echo "Command 2"', { sessionId, timeout: 10000 }); const result5c = await smartExecutor.execute('echo "Command 3"', { sessionId, timeout: 10000 }); const results5 = [result5a, result5b, result5c]; const duration5 = Date.now() - start5; console.log(`Total Duration: ${duration5}ms`); console.log(`All strategies: ${results5.map(r => r.strategyUsed).join(', ')}`); console.log(`All succeeded: ${results5.every(r => r.success) ? 'βœ“' : 'βœ—'}\n`); await consoleManager.stopSession(sessionId); console.log('βœ“ Session stopped\n'); console.log('═'.repeat(60)); console.log('βœ… All Smart Executor tests completed successfully!'); console.log('Key findings:'); console.log('- Command analysis correctly identifies quick commands'); console.log('- Fast path strategy executes with low latency'); console.log('- Unified result format consistent across executions'); console.log('- Sequential command execution works reliably'); console.log('═'.repeat(60)); } catch (error) { console.error('βœ— Test failed:', error); throw error; } } testSmartExecutorWithProfile() .then(() => { console.log('\nβœ“ Test suite completed'); process.exit(0); }) .catch((error) => { console.error('\nβœ— Test suite failed:', error); process.exit(1); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ooples/mcp-console-automation'

If you have feedback or need assistance with the MCP directory API, please join our Discord server