[BUG] 'env' vars from .claude/settings.json not passed to the plugins/mcps.
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?
I have developed a set of Claude code plugins for the company I work for. Part of using the plugins involves adding a settings.json file in the .claude folder within the local repository.
This is how it looks (of course, with secrets and information masked).
{
"env": {
"SET_OF_ENV_VARS": "ENV_VARS_VALUE",
},
"enabledPlugins": {
"plugin_name@plugin_owner": true,
"plugin_name@plugin_owner": true,
"plugin_name@splugin_owner": true
},
"extraKnownMarketplaces": {
"claude-code-plugins": {
"source": {
"source": "github",
"repo": "NAME_OF_PLUGIN_REPO",
}
}
}
}
The issue is that from a few versions onwards (I am not sure which one), you no longer pass the 'env' variables properly. As a result, when using claude --debug, it reports that some ENV vars are missing, even though I have them and it was working perfectly before. Consequently, many MCPs no longer function correctly, or due to their retry mechanisms, it results in duplicated sessions for that MCP (e.g., context7, Serena, etc).
As a note: if I put the env vars inside .env file and I use the MCPs locally directly (not through the plugin or passing .env vars through .claude/settings.json) - it seems to be working.
Let me know if you need more info.
Thanks
What Should Happen?
ENV vars should be passed
Error Messages/Logs
2025-11-18T07:02:43.389Z [DEBUG] Found 5 plugins (4 enabled, 1 disabled)
2025-11-18T07:02:43.389Z [DEBUG] Plugin not available for MCP: plugin_name@plugin_owner - error type: hook-load-failed
2025-11-18T07:02:43.390Z [WARN] Missing environment variables in plugin MCP config: OPENAI_API_KEY, VECTOR_STORE_HOST, VECTOR_STORE_USERNAME, VECTOR_STORE_PASSWORD
2025-11-18T07:02:43.390Z [WARN] Missing environment variables in plugin MCP config: SERENA_PROJECT_PATH
Steps to Reproduce
- Create a plugin that requires environment variables to be passed, for MCPs or other purposes.
- Set it up in a local repository with .claude/settings.json, enabling the plugin and providing the necessary .env variables.
- Attempt to use it and verify that everything functions correctly.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.46 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
Showing cached comments. Read the full discussion on GitHub ↗
15 Comments
Any update on this one?
OTLP Telemetry Not Working Due to Env Var Bug
Version: Claude Code 2.0.65
Platform: macOS
Impact: Critical - All OTLP telemetry stopped working
Issue
Environment variables from
~/.claude/settings.jsonare not being loaded by Claude Code, which breaks OTLP telemetry completely. Theenvsection configuration is correct and validated:Verification
Running
ps eww -p <claude-pid>confirms NO OTEL environment variables are set for the Claude Code process, despite being correctly configured in settings.json.Running
lsof -nP -i4TCP | grep claudeshows Claude Code has NO active connections to the configured OTLP endpoint (port 4317), confirming the env vars aren't being loaded.Impact
This significantly impacts teams using OTLP for monitoring Claude Code usage and costs.
Has this been fixed?
+1
+1
+1
+1
I was seeing this, and it turns out it was because I had
IS_DEMOset in my environment. Removing that fixed the issueAdding diagnostic evidence from a separate reproduction (originally filed as #22571, closing as duplicate).
Reproduction context:
.mcp.jsonin project root with@modelcontextprotocol/server-memory:Confirmed via process inspection:
claude_desktop_config.json):MEMORY_FILE_PATHis set ✅.mcp.json):MEMORY_FILE_PATHis not set ❌Both use identical config — only the Claude Code spawner fails to pass env vars through.
Impact for
server-memoryspecifically: Knowledge graph data is not persisted to the configured file path and is not shared with Claude Desktop, since the server silently falls back to an ephemeral in-memory store with no warning.Environment: macOS Darwin 25.2.0 (arm64), Claude Code latest as of 2026-02-02.
Workaround for anyone hitting this: Use a wrapper script that sets the env vars before exec, then point your MCP config at the wrapper instead of the bare command.
Example for Playwright MCP (needed
PLAYWRIGHT_MCP_BROWSER=chromium):In
~/.claude/.mcp.json:The wrapper sets the env in its own process before exec, so it doesn't depend on Claude Code passing it through. Works for any MCP server that needs env vars.
Full details: https://gist.github.com/prong-raft-squishy/9b1ff44310c90de9fc70c0232d67632f
This bug has been open since November 2025 — over 3 months with
bug,has repro, andarea:mcplabels, yet no assignee or milestone.Multiple users have confirmed the issue with detailed reproduction steps (#22571, #28090 closed as duplicates, #23216 still open separately). The community-suggested wrapper script workaround also doesn't work in the VSCode extension — the extension doesn't even pick up the updated
mcp.json, continuing to spawn the server with the old config.This is a basic contract:
envblock in MCP config should be passed to the spawned process. It worked before, it broke, and it hasn't been fixed.Can someone from the team please prioritize this? cc @bcherny @ant-kurt @fvolcic
This might help partially. I built a config orchestrator that has an env template system —
.env.templategets tracked in git with the variable names,.env.localstays gitignored with the actual values. When you set up on a new machine,mycelium env setupwalks you through filling in the values.Not a full fix for the underlying issue but it makes managing MCP env vars across machines less painful.
https://github.com/bytemines/mycelium
Can confirm this is still an issue. In our case, env variables in plugin
.mcp.jsonwith stdio transport load inconsistently — sometimes they resolve correctly, sometimes they don't, with no changes to the config between sessions. This makes plugin-distributed MCP servers unreliable and hard to debug.Would really appreciate a fix for this.
As a temporary workaround, I wrote a script that merges plugin
.mcp.jsonconfigs into the project-level.mcp.jsonwith env vars interpolated from.claude/settings.local.json. Maybe it helps someone:how is it possible that ts is not fixed yet?