Skip to content

Close stdio input before waiting for server exit - #1838

Draft
luisangelrod wants to merge 2 commits into
modelcontextprotocol:mainfrom
luisangelrod:fix/1836-graceful-stdio-shutdown
Draft

Close stdio input before waiting for server exit#1838
luisangelrod wants to merge 2 commits into
modelcontextprotocol:mainfrom
luisangelrod:fix/1836-graceful-stdio-shutdown

Conversation

@luisangelrod

Copy link
Copy Markdown
Contributor

Summary

  • close the child process's standard input before waiting for stdio server shutdown
  • allow well-behaved servers that exit on EOF to complete graceful cleanup without consuming ShutdownTimeout
  • add a regression test that verifies disposal observes a clean server exit before half of the configured timeout

Validation

  • dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj --filter FullyQualifiedName~StdioClientTransportTests — 54 passed on each of net472, net8.0, net9.0, and net10.0 (216 total)
  • dotnet build -c Release — succeeded with 0 warnings and 0 errors
  • the new regression test was verified to fail against the previous implementation after approximately 4.1 seconds and pass with this change in approximately 1 second

The full test suite was also attempted locally. Unrelated environment dependencies involving the missing Node conformance helper and a localhost OAuth development certificate prevented a clean full-suite completion. One parallel task-cancellation test also failed during that run and passed when rerun in isolation.

Fixes #1836

Note

This pull request description and implementation were prepared with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stdio client never closes the server's stdin, so every client dispose burns the full ShutdownTimeout (5s by default)

1 participant