Configuring node-code-sandbox on Windows with claude_desktop_config.json
The user is trying to configure the node-code-sandbox-mcp with Claude on a Windows machine. They've successfully activated the Node.js Sandbox MCP in Docker Desktop, but are unsure how to correctly configure the claude_desktop_config.json file to enable communication between Claude and the sandbox. They've found a configuration snippet that appears to be designed for Linux, specifically referencing paths like /var/run/docker.sock and a user directory under /Users/YOUR_USERNAME, which are not directly applicable to Windows.
The core problem lies in the different path structures and Docker socket handling between Linux and Windows. The provided Linux configuration mounts the Docker socket directly into the container, allowing the container to control the Docker daemon on the host. It also mounts a specific user directory for output. These approaches need adaptation for Windows.
Solution: Adapting the Configuration for Windows
Here's how to modify the claude_desktop_config.json file for a Windows environment:
First, the docker socket mounting is not usually required on Windows when using Docker Desktop. Docker Desktop handles the communication between the host and the containers. Second, the file path translation is needed.
Here's a possible configuration. Note that you'll need to replace C:/Users/YOUR_USERNAME/Desktop/sandbox-output with the actual path you want to use on your Windows machine.
{
"node-code-sandbox": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"C:/Users/YOUR_USERNAME/Desktop/sandbox-output:/root",
"mcp/node-code-sandbox"
]
}
}
Explanation:
command: Specifies the Docker command to execute.args: An array of arguments passed to the Docker command.-i: Runs the container in interactive mode.--rm: Automatically removes the container after it exits.-v C:/Users/YOUR_USERNAME/Desktop/sandbox-output:/root: This is the crucial part. It creates a volume mount. The part before the colon (:) is the path on your Windows host. The part after the colon is the path inside the Docker container where the host directory will be mounted. In this case, the directoryC:/Users/YOUR_USERNAME/Desktop/sandbox-outputon your Windows machine will be accessible as/rootinside the container. Make sure the Windows directory exists.mcp/node-code-sandbox: The name of the Docker image to run.
Important Considerations:
- File Paths: Ensure the Windows path you specify in the
-vargument exists. Docker Desktop needs to have permission to access the directory. - Docker Desktop Configuration: Verify that Docker Desktop is running and properly configured. It should be able to access the specified directories. Check the "Shared Drives" section in Docker Desktop settings to ensure the drive containing your sandbox output directory is shared with Docker.
- Permissions: Be mindful of file permissions. The user inside the container (usually
root) needs to have the necessary permissions to read and write to the mounted directory. If you encounter permission issues, you might need to adjust the permissions on the Windows host directory or modify the Dockerfile to set appropriate permissions within the container. - Testing: After applying the configuration, test the communication between Claude and the sandbox. Run a simple code snippet that writes output to the mounted directory and verify that the output is accessible on your Windows host.
- Alternative: If you're still having trouble with volume mounts, consider using a shared folder within Docker Desktop.
By adapting the configuration to use Windows-style paths and ensuring Docker Desktop is properly configured, you should be able to successfully integrate the node-code-sandbox-mcp with Claude on your Windows machine.