Skip to content

Conversation

@CBenoit
Copy link
Member

@CBenoit CBenoit commented Nov 4, 2025

Refactor MCP proxy to support server-initiated messages (notifications, progress updates, and server -> client requests) by enabling concurrent reads from both client and server.

Issue: DGW-314

Refactor MCP proxy to support server-initiated messages (notifications,
progress updates, and server -> client requests) by enabling concurrent
reads from both client and server.

Issue: DGW-314
@CBenoit CBenoit requested a review from Copilot November 4, 2025 18:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the MCP proxy implementation to support bidirectional communication and improve cancel safety. The key changes address the need for concurrent read/write operations, particularly for Process and NamedPipe transports.

  • Splits the monolithic forward_request() into separate send_message() and read_message() methods to enable concurrent reading and writing
  • Implements cancel-safe message reading using internal buffers that persist across tokio::select! cancellations
  • Refactors error handling to distinguish between transient and fatal errors with structured SendError and ReadError types

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/mcp-proxy/src/lib.rs Core refactoring: replaces forward_request() with send_message()/read_message(), adds cancel-safe buffering, updates error types, and renames transport structs
jetsocat/src/mcp.rs Rewrites proxy loop to use tokio::select! for concurrent read/write operations with cancel-safe line reading
testsuite/tests/mcp_proxy.rs Updates test cases to use new API (send_message/read_message), verifies new error handling behavior
testsuite/tests/cli/jetsocat.rs Updates error message assertions and adjusts broken pipe test expectations
testsuite/src/mcp_server.rs Adds TODO comment for unsolicited message support
testsuite/src/mcp_client.rs Adds TODO comment for request ID tracking

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CBenoit CBenoit enabled auto-merge (squash) November 4, 2025 18:35
Copy link
Contributor

@pacmancoder pacmancoder left a comment

Choose a reason for hiding this comment

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

LGTM!

@CBenoit CBenoit merged commit acf770f into master Nov 7, 2025
38 checks passed
@CBenoit CBenoit deleted the DGW-314 branch November 7, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants