Skip to content

MCP stdio shutdown does not follow spec #250206

Closed
@connor4312

Description

@connor4312
Member

Ref modelcontextprotocol/typescript-sdk#579

We don't use the TS SDK, but we also don't implement shutdown correctly.

For the stdio transport the client SHOULD initiate shutdown by
- First, closing the input stream to the child process (the server)
- Waiting for the server to exit, or sending SIGTERM if the server does not exit within a reasonable time
- Sending SIGKILL if the server does not exit within a reasonable time after SIGTERM

This is implemented here: https://github.com/microsoft/vscode/blob/main/src/vs/workbench/api/node/extHostMcpNode.ts

We should move away from using the abort controller, have a separate little class for managing connection state. Use a grace time of 2 seconds after each step, and also allow forcefully killing it if $stopMcp is called twice. Use taskkill on Windows or process.kill on posix.

Activity

self-assigned this
on May 31, 2025
added
bugIssue identified by VS Code Team member as probable bug
on May 31, 2025
pavelfeldman

pavelfeldman commented on Jun 1, 2025

@pavelfeldman
Member

Please consider giving us a bit more time to close gracefully upon stdin closure. Browsers will probably take up to 5s on a slow Windows machine.

added this to the June 2025 milestone on Jun 13, 2025
added
insiders-releasedPatch has been released in VS Code Insiders
and removed
unreleasedPatch has not yet been released in VS Code Insiders
on Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugdebtCode quality issuesinsiders-releasedPatch has been released in VS Code Insiders

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @pavelfeldman@connor4312

    Issue actions

      MCP stdio shutdown does not follow spec · Issue #250206 · microsoft/vscode