[BUG] MCP server env block in ~/.claude.json not passed to spawned MCP servers inside Dev Container

Resolved 💬 3 comments Opened Apr 25, 2026 by sergii-tereshchenko Closed Apr 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Environment
Claude Code: 2.1.119
VS Code: 1.116.0
Dev Containers extension: 0.454.0
Host: macOS, Docker Desktop 4.67.0, image mcr.microsoft.com/devcontainers/go:1.25
Steps to reproduce
On host, configure an MCP server in ~/.claude.json with an env block containing a credential, e.g.:

"mcpServers": {
"codex": {
"type": "stdio",
"command": "codex",
"args": ["mcp-server"],
"env": { "OPENAI_API_KEY": "sk-proj-..." }
}
}
Bind-mount ~/.claude.json into a Dev Container so Claude Code in the container reads the same file.
Open a Claude session inside the container and call a tool routed through the codex MCP server.
Expected
The MCP server starts with OPENAI_API_KEY set in its environment (same behavior as host).

Actual
The MCP server starts but the env var is empty. API calls fail with 401 Unauthorized — Missing bearer or basic authentication in header.

Verified manually in the container:

echo '{"jsonrpc":"2.0","id":1,"method":"initialize",...}' \
| OPENAI_API_KEY="$KEY" codex mcp-server
…returns a normal init response. So the codex binary honors env-var auth fine — Claude Code just isn't passing the configured env block.

Workaround
Add the env var to the Dev Container's remoteEnv (e.g. "OPENAI_API_KEY": "${localEnv:OPENAI_API_KEY}") so it's set process-wide and inherited by the spawned MCP server.

What Should Happen?

The MCP server starts with OPENAI_API_KEY set in its environment (same behavior as host).

Error Messages/Logs

The MCP server starts but the env var is empty. API calls fail with 401 Unauthorized — Missing bearer or basic authentication in header.

Verified manually in the container:


echo '{"jsonrpc":"2.0","id":1,"method":"initialize",...}' \
  | OPENAI_API_KEY="$KEY" codex mcp-server
…returns a normal init response. So the codex binary honors env-var auth fine — Claude Code just isn't passing the configured env block.

Steps to Reproduce

On host, configure an MCP server in ~/.claude.json with an env block containing a credential, e.g.:

"mcpServers": {
"codex": {
"type": "stdio",
"command": "codex",
"args": ["mcp-server"],
"env": { "OPENAI_API_KEY": "sk-proj-..." }
}
}
Bind-mount ~/.claude.json into a Dev Container so Claude Code in the container reads the same file.
Open a Claude session inside the container and call a tool routed through the codex MCP server.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.119

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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