Skip to content

Align stdio shutdown sequence with spec #765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davenpi
Copy link

@davenpi davenpi commented May 21, 2025

Align the stdio shutdown sequence with the MCP spec: close the server’s input, wait for exit, send SIGTERM if needed, and SIGKILL as a last resort.

Motivation and Context

The MCP spec recommends a careful shutdown sequence for stdio transport to avoid leaving orphaned or stuck server processes. This change follows those steps, making shutdowns more reliable and predictable.

How Has This Been Tested?

All tests pass (except one unrelated skipped test).

Breaking Changes

None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

None

@davenpi
Copy link
Author

davenpi commented May 22, 2025

Hey @ihrpr! Do you have a sec to review this PR? It makes the SDK follow the stdio shutdown procedure to the letter!

@davenpi davenpi force-pushed the fix/stdio-shutdown-spec branch from 35eaaaf to b997748 Compare May 22, 2025 12:00
@ihrpr ihrpr added this to the r-05-25 milestone May 23, 2025
@ihrpr
Copy link
Contributor

ihrpr commented May 28, 2025

related PR: #555

@ihrpr ihrpr modified the milestones: r-05-25, stdio shutdown May 28, 2025
Copy link
Contributor

@ihrpr ihrpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @davenpi for working on this.

There are a lot of issues reported around the shutdown for stdio, if would be great to have additional tests and verify on different platforms that the solution works.

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.

2 participants