Skip to content

Refactor transports to help enable graceful shutdown#142

Merged
halter73 merged 12 commits into
modelcontextprotocol:mainfrom
halter73:gracefulshutdown
Mar 31, 2025
Merged

Refactor transports to help enable graceful shutdown#142
halter73 merged 12 commits into
modelcontextprotocol:mainfrom
halter73:gracefulshutdown

Conversation

@halter73
Copy link
Copy Markdown
Contributor

I took this over from #122

  • This also paves the way for better multi-session support
  • We should definitely rethink names for the transport API. But for now, I kept the names similar as possible, so we can focus on the API shape.

stephentoub and others added 5 commits March 27, 2025 18:13
# Conflicts:
#	src/ModelContextProtocol/Client/McpClient.cs
#	src/ModelContextProtocol/Protocol/Transport/StdioServerTransport.cs
- This also paves the way for better multi-session support
- We should definitely rethink names for the transport API
- For now, I kept the names similar as possible, so we can
  focus on the API shape
@halter73 halter73 mentioned this pull request Mar 29, 2025
Comment thread src/ModelContextProtocol/Client/McpClient.cs Outdated
Comment thread src/ModelContextProtocol/Client/McpClientFactory.cs
- Use SemaphoreSlim in McpJsonRpcEndpoint
- Dispose IClientTransport on connection failure
- Test cleanup
@halter73
Copy link
Copy Markdown
Contributor Author

The faster test runs after these changes are really nice.

csharp-sdk [main] > dotnet test --filter ModelContextProtocol.Tests.ClientIntegrationTests
...
Test summary: total: 41, failed: 0, succeeded: 39, skipped: 2, duration: 96.3s
csharp-sdk [main] > checkout gracefulshutdown
csharp-sdk [main] > dotnet test --filter ModelContextProtocol.Tests.ClientIntegrationTests
...
Test summary: total: 41, failed: 0, succeeded: 39, skipped: 2, duration: 37.8s

@stephentoub
Copy link
Copy Markdown
Contributor

Yeah, those 15-30s sleeps in the tests were killer.

Comment thread src/ModelContextProtocol/Hosting/McpServerMultiSessionHostedService.cs Outdated
Comment thread src/ModelContextProtocol/Hosting/McpServerSingleSessionHostedService.cs Outdated
Comment thread src/ModelContextProtocol/Protocol/Transport/HttpListenerSseServerTransport.cs Outdated
Comment thread src/ModelContextProtocol/Protocol/Transport/StdioClientTransport.cs
Comment thread src/ModelContextProtocol/Server/McpServer.cs Outdated
Comment thread src/ModelContextProtocol/Shared/McpJsonRpcEndpoint.cs
@halter73 halter73 merged commit 2ab9db0 into modelcontextprotocol:main Mar 31, 2025
8 checks passed
@cristipufu
Copy link
Copy Markdown

cristipufu commented Mar 31, 2025

@halter73 @stephentoub how should we handle multi-nodes deployments?
eg:

  • session connects to sse on node1
  • session makes tool call request on node2
  • need to send tool call updates for session on node1

@jeffhandley
Copy link
Copy Markdown
Contributor

Adding the breaking-change label retroactively during release notes revision.

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

Labels

breaking-change This issue or PR introduces a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants