-
Notifications
You must be signed in to change notification settings - Fork 652
Description
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"
}
}
}