check_wsl_status
Check WSL2 status and retrieve distribution details to verify Windows Subsystem for Linux functionality and configuration.
Instructions
Check WSL2 status and get distribution information
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "check_wsl_status"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:627-691 (handler)The handler function that implements the check_wsl_status tool. It checks WSL status using 'wsl -l -v', tests connection to the distribution, retrieves OS info from /etc/os-release, and returns a JSON-formatted response with status details.
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:267-270 (schema)The input schema for the check_wsl_status tool, which requires no parameters (empty properties).
inputSchema: { type: "object", properties: {}, }, - src/index.js:264-293 (registration)Registration of the check_wsl_status tool in the ListTools handler (lines 264-271) and dispatch in the CallToolRequestSchema switch case (lines 292-293), including description and schema.
{ name: "check_wsl_status", description: "Check WSL2 status and get distribution information", inputSchema: { type: "object", properties: {}, }, } ], }; }); this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; console.error(`[DEBUG] Tool request: ${name}`, args); try { switch (name) { case "execute_bash_command": return await this.executeBashCommand(args); case "execute_bash_script": return await this.executeBashScript(args); case "create_bash_script": return await this.createBashScript(args); case "list_directory": return await this.listDirectory(args); case "get_system_info": return await this.getSystemInfo(); case "check_wsl_status": return await this.checkWSLStatus();