Windows: MCP worker survives exit when launched through a wrapper
Describe the bug
Problem: Exiting the session terminates the MCP launch wrapper but leaves its descendant worker running.
Affected launch chain:
cmd.exe /c run-server.cmd
`- dotnet run --no-build --project ExampleMcpServer.csproj
`- ExampleMcpServer.exe
Affected version
GitHub Copilot CLI 1.0.88.
Steps to reproduce the behavior
- Configure a local stdio MCP server to launch through a
.cmdwrapper runningdotnet run. - Start Copilot and wait for the server to initialize.
- Exit the session.
- Observe that the wrapper terminates but the MCP worker remains alive.
Expected behavior
Terminate the complete session-owned MCP process tree, allowing a bounded graceful shutdown.
Additional context
Suggested fix (copilot generated): Own the process tree using a Windows Job Object with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. Assign the initial process before it spawns descendants. Cover normal exit, supervisor crashes, and shutdown during startup or an active request.
The Windows Job Object suggestion looks right, but I would make the cross-platform ownership contract explicit:
every locally spawned MCP process tree belongs to one supervisor scope and must be gone after that scope closes.
Windows: Job Object with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE.
Unix: process group/session ownership with graceful signal followed by bounded kill.
Regression cases worth covering:
- direct child;
.cmd/shell wrapper with grandchild;- supervisor crash;
- exit during MCP startup;
- exit during active request;
- child that ignores graceful shutdown.
The test should assert on the descendant worker PID, not only the wrapper PID.
- child that ignores graceful shutdown.
This might be considered as feature: on 1st run start background worker that serves multiple parallel and/or consecutive sessions. But of course, in scope of this issue, it can be deferred or completely ignored until somebody asks for such feature.
بخدا من دزد نیستم میخوام خودم دستم جیب خودمم باش لطفا کمک کنید تا سفید بال خودم مادرم خواهرم رو وصل کنم
در تاریخ دوشنبه ۲۸ سپتامبر ۲۰۲۶، ۰۹:۱۴ Sven Suursoho < @.***> نوشت:
svens left a comment (github/copilot-cli#4972) https://github.com/github/copilot-cli/issues/4972#issuecomment-5864185173
- child that ignores graceful shutdown.
This might be considered as feature: on 1st run start background worker that serves multiple parallel and/or consecutive sessions. But of course, in scope of this issue, it can be deferred or completely ignored if nobody asks for such feature.
— Reply to this email directly, view it on GitHub https://github.com/github/copilot-cli/issues/4972?email_source=notifications&email_token=BMBZYCUSQ4O7ZYYPZEDUFSL5RH3CDA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKOBWGQYTQNJRG4Z2M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-5864185173, or unsubscribe https://github.com/notifications/unsubscribe-auth/BMBZYCTHYRRJSQKVBXFRCWD5RH3CDAVCNFSNUABFKJSXA33TNF2G64TZHM2TQNJYGYYDMNRUHNEXG43VMU5TKNJZGIZTGNBWGM42C5QC . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@svens Windows process launch and teardown for MCP servers have changed several times since 1.0.88. Could you retest on 1.0.114 with the same wrapper? If the worker still survives, please share the wrapper command and a --log-level debug log, especially any 'failed to assign/configure Job Object' lines.
Can confirm, issue does not reproduce with version 1.0.114