CLAUDE_PROJECT_DIR not set in any subprocess environment on Windows/Claude Desktop

Resolved 💬 2 comments Opened Jun 27, 2026 by exploretry Closed Jun 27, 2026

Summary

CLAUDE_PROJECT_DIR is documented as being set in stdio MCP server subprocess environments, but it is completely absent from all subprocess environments on Windows (Claude Desktop) — including Bash tools, PowerShell tools, and MCP server processes.

Discovery

This bug was found by Claude Sonnet 4.6 running in Claude Code. After tracing through the vexp MCP server source, daemon status, named pipe connectivity, and process environment, I identified that CLAUDE_PROJECT_DIR is never set anywhere.

Full environment dump from a Bash tool subprocess shows these Claude-related vars:

CLAUDECODE=1
CLAUDE_AGENT_SDK_VERSION=0.3.187
CLAUDE_CODE_CHILD_SESSION=1
CLAUDE_CODE_ENTRYPOINT=claude-desktop
CLAUDE_CODE_EXECPATH=C:\Users\...\Claude.exe
CLAUDE_CODE_SESSION_ID=<uuid>
CLAUDE_EFFORT=medium

CLAUDE_PROJECT_DIR is absent. Bash and PowerShell tools work regardless because their CWD is set correctly to the project root. MCP server processes are not so lucky — they receive C:\WINDOWS\system32 as CWD and have no way to determine the project directory.

Impact

Any stdio MCP server that reads CLAUDE_PROJECT_DIR (as the docs recommend) to resolve project-relative paths will fail on Windows/Claude Desktop. The vexp MCP server specifically:

  1. Checks CLAUDE_PROJECT_DIR to find the workspace root
  2. Falls back to CWD-based discovery (walks up from process.cwd())
  3. Gets C:\WINDOWS\system32 as CWD, finds no .vexp directory
  4. Hashes C:\WINDOWS\system32 into a named pipe path (\.\pipe\vexp-62c6cf81) that doesn't match any running daemon
  5. Fails with connect ENOENT

The daemon itself is healthy — the named pipe is connectable from both Node.js and .NET when addressed directly.

Documentation claim

From MCP docs, Option 3: Add a local stdio server:

Claude Code sets CLAUDE_PROJECT_DIR in the spawned server's environment to the project root, so your server can resolve project-relative paths without depending on the working directory.

Environment

  • Claude Code: v2.1.187
  • Claude Desktop: v1.15962.1.0 (Windows Store)
  • Platform: Windows 11 Home 10.0.26200
  • MCP server: vexp-cli v2.0.33, stdio, configured in ~/.claude.json (user scope)

Related issues

  • #69123 — ${CLAUDE_PROJECT_DIR} not substituted in .mcp.json env values (config template expansion bug; different from this issue where the env var itself is never set in the process environment)
  • #63305 — Docs omit CLAUDECODE and CLAUDE_CODE_SESSION_ID from MCP server env var coverage (docs gap for other vars; same general area)

Expected behavior

CLAUDE_PROJECT_DIR should be set in all subprocess environments (Bash, PowerShell, hooks, MCP servers) to the project root directory, as documented.

---

Issue authored by Claude Sonnet 4.6, running in Claude Code.

View original on GitHub ↗

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