check_wsl_status
Verify the status of WSL2 and retrieve details about installed Linux distributions on a Windows system to ensure proper functionality and integration.
Instructions
Check WSL2 status and get distribution information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:627-691 (handler)The primary handler function for the 'check_wsl_status' tool. It executes WSL commands to list distributions with versions, tests connectivity to the configured distribution, retrieves OS release information, and formats the results into a structured JSON response for the MCP protocol.async checkWSLStatus() { try { // Check WSL status const { stdout: wslList } = await execAsync("wsl -l -v"); // Try to execute a simple command in the selected distribution let testOutput = "Not tested"; let osInfo = "Not available"; if (this.wslDistribution) { try { const { stdout: testResult } = await execAsync(`wsl -d ${this.wslDistribution} -- echo 'WSL connection test successful'`); testOutput = testResult.trim(); } catch (error) { testOutput = `Test failed: ${error.message}`; } // Get distribution-specific information try { const { stdout: osResult } = await execAsync(`wsl -d ${this.wslDistribution} -- cat /etc/os-release`); osInfo = osResult.trim(); } catch (error) { osInfo = `OS info not available: ${error.message}`; } } return { content: [ { type: "text", text: JSON.stringify({ success: true, wslStatus: "Running", selectedDistribution: this.wslDistribution || "Not configured", allDistributions: wslList.trim(), testOutput: testOutput, osInfo: osInfo, serverConfig: { configuredDistribution: this.config?.wslDistribution, defaultTimeout: this.config?.defaultTimeout, scriptTimeout: this.config?.scriptTimeout, debugMode: this.config?.debugMode }, timestamp: new Date().toISOString() }, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify({ success: false, wslStatus: "Error", selectedDistribution: this.wslDistribution || "Not configured", error: error.message, timestamp: new Date().toISOString() }, null, 2), }, ], }; } }
- src/index.js:264-271 (registration)Tool registration entry in the ListToolsRequestSchema handler, defining the tool's name, description, and input schema (empty object, no parameters required).{ name: "check_wsl_status", description: "Check WSL2 status and get distribution information", inputSchema: { type: "object", properties: {}, }, }
- src/index.js:292-293 (registration)Dispatch logic in the CallToolRequestSchema handler's switch statement that maps the 'check_wsl_status' tool call to the checkWSLStatus method.case "check_wsl_status": return await this.checkWSLStatus();
- src/index.js:267-270 (schema)Input schema definition for the check_wsl_status tool: an empty object indicating no input parameters are required.inputSchema: { type: "object", properties: {}, },