MCP server env vars from .mcp.json not passed to spawned process
Resolved 💬 5 comments Opened Feb 2, 2026 by edumusikse Closed Feb 2, 2026
Description
Environment variables defined in .mcp.json under a server's env key are not being passed to the spawned MCP server process. This means MCP servers that depend on env-based configuration (like @modelcontextprotocol/server-memory with MEMORY_FILE_PATH) silently fall back to defaults.
Steps to Reproduce
- Create
.mcp.jsonin a project root:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"],
"env": {
"MEMORY_FILE_PATH": "/Users/me/.claude-memory/memory.json"
}
}
}
}
- Start a Claude Code session in that project directory
- Use a memory MCP tool (e.g.,
mcp__memory__search_nodes) - Inspect the spawned
mcp-server-memoryprocess environment:
ps eww -p <PID> | grep MEMORY_FILE_PATH
Expected Behavior
The process should have MEMORY_FILE_PATH=/Users/me/.claude-memory/memory.json in its environment, and the MCP memory server should read/write to that file.
Actual Behavior
MEMORY_FILE_PATHis not set on the spawned process (confirmed viaps eww)- The server uses an ephemeral in-memory store instead of the configured file
- Data written via Claude Code's MCP tools is lost on server restart
- The same
.mcp.jsonenv config works correctly when used by Claude Desktop viaclaude_desktop_config.json
Diagnostic Evidence
# Claude Desktop's server (PID from Claude.app) — env var present:
MEMORY_FILE_PATH=/Users/me/.claude-memory/memory.json
# Claude Code's server (PID from npx) — env var missing:
MEMORY_FILE_PATH not set
Both servers use identical config ("env": {"MEMORY_FILE_PATH": "..."}) — only the Claude Code spawner fails to pass it through.
Impact
- MCP servers that rely on env vars for configuration silently malfunction
- No error or warning is shown — the server starts fine but with wrong config
- For
server-memoryspecifically: knowledge graph data is not persisted and not shared with Claude Desktop, defeating the purpose of a shared memory store
Environment
- macOS (Darwin 25.2.0, arm64)
- Claude Code (latest as of 2026-02-02)
@modelcontextprotocol/server-memoryvia npx.mcp.jsonin project root
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗