UNPKG

ludus-mcp

Version:

MCP server for managing Ludus cybersecurity training environments through natural language commands

179 lines 5.36 kB
import { Logger } from '../utils/logger.js'; import { LudusConfig } from './interactiveSetup.js'; export interface CommandResult { success: boolean; data?: any; message: string; rawOutput?: string; } export declare class LudusCliWrapper { private logger; private config; private sshTunnelPid; private sshTunnelPort; private regularTunnelPid; private tunnelManager?; private baseCwd; constructor(logger: Logger, config: LudusConfig); /** * Initialize the SSH tunnel manager using ssh2 library */ private initializeTunnelManager; /** * Ensure SSH tunnels are healthy before executing commands */ private ensureTunnelsHealthy; /** * Check if a command requires admin API (SSH tunnel) */ private isAdminCommand; /** * Set up environment variables for regular API calls via WireGuard */ private setupWireGuardEnvironment; /** * Set up environment variables for regular API calls via SSH tunnel (port 8080) */ private setupSSHTunnelRegularEnvironment; /** * Set up environment variables for admin API calls via SSH tunnel (port 8081) */ private setupSSHTunnelAdminEnvironment; /** * Create SSH tunnel for admin operations using tunnel manager */ private createSSHTunnel; /** * Create SSH tunnel for regular operations using tunnel manager */ private createRegularOperationsTunnel; /** * Execute command with smart routing */ executeCommand(command: string, args?: string[], workingDirectory?: string): Promise<CommandResult>; /** * Execute arbitrary Ludus CLI command */ executeArbitraryCommand(command: string, args?: string[]): Promise<CommandResult>; /** * List user ranges (current user or specific user for admin) */ listUserRanges(user?: string): Promise<CommandResult>; /** * Deploy range with full CLI options support */ deployRange(options?: { user?: string; configPath?: string; force?: boolean; tags?: string; limit?: string; onlyRoles?: string; verboseAnsible?: boolean; }): Promise<CommandResult>; /** * Get available deployment tags */ getTags(user?: string): Promise<CommandResult>; /** * Abort range deployment */ abortRange(user?: string): Promise<CommandResult>; /** * Get range status (current user or specific user for admin) */ getRangeStatus(user?: string): Promise<CommandResult>; /** * Destroy range - permanently remove all VMs and free resources */ destroyRange(user?: string, noPrompt?: boolean): Promise<CommandResult>; /** * Get RDP connection files for Windows VMs */ getRangeRdpInfo(user?: string): Promise<CommandResult>; /** * Get WireGuard configuration for user */ getUserWireguardConfig(user?: string): Promise<CommandResult>; /** * Get /etc/hosts formatted file for range */ getRangeEtcHosts(user?: string): Promise<CommandResult>; /** * Power on VMs in range */ powerOnRange(user?: string, vmNames?: string): Promise<CommandResult>; /** * Power off VMs in range */ powerOffRange(user?: string, vmNames?: string): Promise<CommandResult>; /** * Get range configuration */ getRangeConfig(user?: string): Promise<CommandResult>; /** * Set range configuration from file */ setRangeConfig(configPath: string, user?: string, force?: boolean): Promise<CommandResult>; /** * Get range deployment logs */ getRangeLogs(user?: string, follow?: boolean): Promise<CommandResult>; /** * List available templates */ listTemplates(): Promise<CommandResult>; /** * Get user information for a specific user (or current user if none specified) */ getUserInfo(user?: string): Promise<CommandResult>; /** * List all users in the system */ listAllUsers(): Promise<CommandResult>; /** * Add a new user (admin operation) */ addUser(name: string, userId: string, isAdmin?: boolean): Promise<CommandResult>; /** * Remove a user (admin operation) */ removeUser(userId: string): Promise<CommandResult>; /** * Get API key for user (admin operation) */ getUserApiKey(userId: string): Promise<CommandResult>; /** * Test connectivity for both regular and admin operations */ testConnectivity(): Promise<{ rangeOps: boolean; adminOps: boolean; }>; /** * Check if WireGuard is currently connected */ private checkWireGuardConnectivity; /** * Check if WireGuard is available on the system */ private checkWireGuardAvailable; /** * Check WireGuard health by pinging the WireGuard interface * Returns health status and suggestions for the user */ private checkWireGuardHealth; /** * Ensure base directory exists */ private ensureBaseDirectory; /** * Get or create user-specific directory for file downloads */ private ensureUserDirectory; /** * Cleanup resources including SSH tunnel manager */ cleanup(): Promise<void>; } //# sourceMappingURL=cliWrapper.d.ts.map