Native (PowerShell) installer: MCP child processes don't inherit system environment variables on Windows

Resolved 💬 2 comments Opened Mar 20, 2026 by AbigYang Closed Apr 17, 2026

Bug Description

When Claude Code is installed via the native installer (PowerShell) on Windows, MCP servers spawned as child processes do not inherit system environment variables (e.g., LOCALAPPDATA, APPDATA, USERPROFILE).

This causes MCP servers that rely on these variables to fail. For example, chrome-devtools-mcp --autoConnect cannot locate Chrome's DevToolsActivePort file because LOCALAPPDATA is undefined in the child process.

Environment

  • OS: Windows 11 Home
  • Claude Code: Native installer (PowerShell), v2.1.80
  • Chrome: v146 (auto-enables debug port on 9222)
  • MCP: chrome-devtools-mcp@0.20.2

Steps to Reproduce

  1. Install Claude Code via native installer (PowerShell)
  2. Configure chrome-devtools-mcp with --autoConnect:

``json
"chrome-devtools": {
"type": "stdio",
"command": "npx",
"args": ["chrome-devtools-mcp@latest", "--autoConnect"]
}
``

  1. Open Chrome (v144+, which auto-enables debug port)
  2. In Claude Code, use any chrome-devtools tool (e.g., list_pages)

Expected: MCP connects to Chrome successfully.

Actual: Error: Could not find DevToolsActivePort for chrome at C:\Users\<user>\AppData\Local\Google\Chrome\User Data\DevToolsActivePort

The file exists and is readable, but the MCP child process doesn't have LOCALAPPDATA set.

Root Cause

The native installer appears to spawn MCP child processes without inheriting the parent process's environment variables. This is equivalent to Node.js child_process.spawn() being called with { env: {} } instead of { env: process.env }:

// Simulates the behavior
const { execSync } = require('child_process');
execSync('node -e "console.log(process.env.LOCALAPPDATA)"', { env: {} });
// Output: "undefined"

execSync('node -e "console.log(process.env.LOCALAPPDATA)"', { env: process.env });
// Output: "C:\Users\<user>\AppData\Local"

Workaround

Wrap the MCP command with cmd /c so that cmd.exe loads the full system environment:

  1. Create %USERPROFILE%\.claude\chrome-mcp.cmd:

``cmd
@echo off
npx chrome-devtools-mcp@latest --autoConnect %*
``

  1. Update MCP config in .claude.json:

``json
"chrome-devtools": {
"type": "stdio",
"command": "cmd",
"args": ["/c", "C:\Users\<user>\.claude\chrome-mcp.cmd"]
}
``

Notes

  • This does not occur when Claude Code is installed via npm install -g @anthropic-ai/claude-code — npm-installed version correctly inherits environment variables.
  • This likely affects all MCP servers on Windows that depend on system environment variables, not just chrome-devtools-mcp.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗