Conversation
961e573 to
e4ffff9
Compare
There was a problem hiding this comment.
Pull request overview
This PR incorporates review feedback into RFC THV-0038, which proposes a session-scoped client lifecycle architecture for the vMCP (virtual MCP) server. The RFC introduces a new Session interface that owns backend MCP clients throughout the session lifetime, replacing the current per-request client creation pattern.
Changes:
- Enhanced thread-safety documentation to use WaitGroup pattern instead of context cancellation for coordinating Close() operations
- Clarified backend initialization concurrency as per-session bounded (not global)
- Improved error messages for empty-capability sessions to be more actionable
- Added explicit locking pattern in CallTool to release locks before network I/O
- Removed redundant log statement in reinitializeBackend
- Added detailed keepalive implementation guidance (ping preference, failure handling, metrics)
- Enhanced authentication credential recreation with singleflight, latency documentation, and proactive refresh guidance
- Improved resource exhaustion mitigation with Retry-After header and security considerations
- Clarified "Eager session pre-initialization" terminology
- Added blocking security requirement for token hash binding before production rollout
- Enhanced testing criteria for high-throughput tests with specific success metrics
- Clarified session cleanup pattern using optional interface check
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
rfcs/THV-0038-session-scoped-client-lifecycle.md:1121
- This example performs
CreateClient(...)(which includes an Initialize handshake / network I/O) while holdings.mu.Lock(). That can block unrelated tool calls and even deadlock if any callbacks touch session state. Consider doing the slow client creation outside the lock, then acquiring the lock briefly to validate state and swap in the new client (or usesingleflight/per-backend mutex to serialize only this backend’s reinit).
// Create NEW client (triggers new Initialize handshake with backend)
// This sends InitializeRequest to backend MCP server
newClient, err := s.clientFactory.CreateClient(ctx, backend, s.identity)
if err != nil {
return fmt.Errorf("client creation failed: %w", err)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
895c6c8 to
f8c8edd
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
301195b to
8308910
Compare
8308910 to
8a12233
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.