WslContainerMcp
Stdio mcp server that gives full access to a linux container from Windows. Requires wsl.
Ask AI about WslContainerMcp
Powered by Claude Β· Grounded in docs
I know everything about WslContainerMcp. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
WslContainerMcp
A Windows-only MCP server that gives any MCP-aware AI agent full access to a Linux container running inside WSL via Podman.
How It Works
The server communicates over stdio (stdin/stdout) and always exposes exactly one tool depending on whether the environment is ready:
| Environment state | Tool exposed |
|---|---|
| Everything ready | run_linux_cli |
| Any issue (WSL, Podman, etc.) | environment_issue_report |
Calling environment_issue_report returns a plain-language description of what went wrong and step-by-step instructions to fix it β so users can resolve issues without leaving their AI chat.
The server attempts to fix problems automatically where possible:
- WSL not installed β tries
wsl --install --no-launchautomatically - No Linux distro β tries
wsl --install -d Ubuntu --no-launchautomatically - Shell not responding β tries
wsl --shutdownand retries automatically - Podman not installed β installs via
apt-get/dnf/apkautomatically - Agent image missing β builds from the embedded Dockerfile automatically
Requirements
- Windows 10/11 (WSL 2 must be supported)
- WSL 2 (installed automatically on first run if missing)
- A Linux distribution in WSL (Ubuntu is installed automatically if none is present)
- Podman (installed automatically inside WSL if missing, requires passwordless
sudo)
Quick Start
# Option A: run directly (requires .NET 10 SDK)
dotnet run
# Option B: publish self-contained exe and run it
dotnet publish -c Release
.\bin\Release\net10.0-windows\win-x64\publish\WslContainerMcp.exe
Server Flags
| Flag | Description |
|---|---|
--no-network | Start containers with --network none (no internet access) |
Registering with an MCP Client
Add to your MCP client configuration (e.g. Claude Desktop claude_desktop_config.json):
{
"mcpServers": {
"WslContainerMcp": {
"command": "C:\\path\\to\\WslContainerMcp.exe"
}
}
}
To block container internet access:
{
"mcpServers": {
"WslContainerMcp": {
"command": "C:\\path\\to\\WslContainerMcp.exe",
"args": ["--no-network"]
}
}
}
Tool: run_linux_cli
Runs a command inside a fresh wsl-sandbox-mcp-agent:latest Podman container.
Input
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
cmd | string | β | β | Executable to run (e.g. python3, bash) |
args | string[] | β | β | Arguments to pass to the executable |
cwd | string | "." | Working directory, relative to workspace root | |
timeout_s | int | 120 | Timeout in seconds (clamped to 1β3600) | |
env | object<string, string> | {} | Extra environment variables for the container |
cwd must be a relative path. Absolute paths, drive prefixes, and .. segments are rejected.
Output (JSON)
| Field | Type | Description |
|---|---|---|
exit_code | int | Process exit code (0 = success) |
stdout | string | Captured standard output |
stderr | string | Captured standard error |
timed_out | bool | Whether the command was killed due to timeout |
artifact_meta | string | Relative path to call metadata JSON (optional) |
Workspace & File Access
All data is stored under %USERPROFILE%\.wsl-sandbox-mcp\ (one workspace per Windows user β no cross-user mixing):
%USERPROFILE%\.wsl-sandbox-mcp\
βββ workspace\ β mounted as /workspace inside every container
β βββ out\ β call metadata JSON files
βββ container\
β βββ Dockerfile β auto-extracted; used to build the agent image
Inspecting files from inside the container
The workspace is mounted at /workspace inside every container. Any file written to /workspace during a run is immediately visible from Windows at:
%USERPROFILE%\.wsl-sandbox-mcp\workspace\
For example, a command that writes to /workspace/result.txt can be read on Windows at:
%USERPROFILE%\.wsl-sandbox-mcp\workspace\result.txt
Inspecting Podman image storage (via \\wsl$)
Podman stores images and layers in a stable per-user directory inside WSL:
\\wsl$\<DistroName>\home\<linuxuser>\.wsl-sandbox-mcp\podman\
βββ graphroot\ β image layers
βββ runroot\ β runtime state
Open this path directly in Windows Explorer.
Project Structure
WslContainerMcp/
βββ Program.cs β Minimal startup (WSL/Podman bootstrap β MCP server)
βββ AgentDockerfile.cs β Embedded Dockerfile content (self-contained)
βββ WslContainerMcp.csproj
βββ Runtime/
β βββ BootstrapResult.cs β DI-shared state from startup bootstrap
β βββ LinuxCliRunner.cs β run_linux_cli core logic
β βββ PathMapping.cs β Windows β WSL path conversion + cwd sanitization
β βββ PodmanBootstrap.cs β Podman setup: storage config, install, image build
β βββ ProcessExec.cs β Low-level process/WSL execution helpers
β βββ WslBootstrap.cs β WSL availability checks + auto-fix attempts
β βββ WslProbe.cs β Low-level WSL probes (no side effects)
βββ Tools/
β βββ RunLinuxCliTool.cs β MCP tool: run_linux_cli
β βββ EnvironmentIssueReportTool.cs β MCP tool: environment_issue_report (fallback)
βββ Container/
βββ Dockerfile β Source for wsl-sandbox-mcp-agent:latest
