Skip to content

Conversation

greenhat616
Copy link

Close #493

I’m adding a cancellation token to Streamable HTTP to support graceful shutdowns. Because I’m unclear on the MCP protocol’s semantics for initiating termination, I’m currently just cutting off the body stream.

Motivation and Context

In desktop apps, we need a mechanism for the process to proactively terminate (e.g., for updates or user-initiated quits). Today, the MCP Client holds the connection open, which effectively prevents the app from shutting down; most users aren’t aware this is intentional client behavior.

How Has This Been Tested?

Breaking Changes

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

@github-actions github-actions bot added T-core Core library changes T-examples Example code changes T-transport Transport layer changes labels Oct 21, 2025
@greenhat616
Copy link
Author

I checked the doc: https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle#shutdown

It seems that trigger a connection close is enough

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

Labels

T-core Core library changes T-examples Example code changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gracefully shutdown is hang while a SSE connection is established

1 participant