[Bug] MCP server loses environment variables on automatic restart after GitHub authentication
Describe the bug
When Copilot CLI automatically restarts an MCP server after GitHub authentication, the environment variables defined in mcp-config.json are not passed to the restarted process.
This causes any MCP server relying on environment variables (e.g., for API tokens or configuration) to fail or crash immediately after the restart (approx. 5-10 seconds after initial startup)
Affected version
0.0.367 (and 0.0.368-2)
Steps to reproduce the behavior
- Configure a local MCP server in ~/.copilot/mcp-config.json that relies on environment variables (e.g., HELLO_VAR).
- Start Copilot CLI (or VS Code with Copilot).
- Observe the first startup logs: the environment variables are correctly present.
- Interact with Copilot to trigger GitHub MCP authentication.
- Wait for the automatic restart message: "GitHub MCP server configured after authentication".
- Observe the logs for the restarted process: the environment variables are missing (undefined).
Expected behavior
Environment variables defined in mcp-config.json should be consistently passed to the MCP server process on every startup, including automatic restarts triggered by the Copilot CLI lifecycle (e.g., after GitHub authentication).
[2025-12-09T19:21:26.047Z] [PID:61339] CHECK: HELLO_VAR=WORLD [2025-12-09T19:21:26.051Z] [PID:61339] Server started [2025-12-09T19:21:29.552Z] [PID:61416] CHECK: HELLO_VAR=MISSING [2025-12-09T19:21:29.556Z] [PID:61416] Server started
The restarted process should have the same environment context as the initial process.
"mcpServers":{
"repro-test":{
"type":"local",
"command":"node",
"tools":[
"ping"
],
"args":[
"/absolute/path/to/debug-repro.js"
],
"env":{
"HELLO_VAR":"WORLD"
}
}
}
This should be resolved as of v1.0.16. MCP servers now load correctly after login, user switches, and /mcp reload, which includes the automatic restart triggered by GitHub authentication that caused env vars to be dropped. If you're still seeing this, please reopen this issue.