Skip to content

Conversation

@CBenoit
Copy link
Member

@CBenoit CBenoit commented Oct 28, 2025

When the MCP server connection breaks (process died, pipe closed), the proxy now detects this and stops forwarding requests instead of continuing to fail on each subsequent request.

When the MCP server connection breaks (process died, pipe closed),
the proxy now detects this and stops forwarding requests instead of
continuing to fail on each subsequent request.
@CBenoit CBenoit requested a review from Copilot October 28, 2025 12:15
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 adds robust handling for broken pipe scenarios in the MCP proxy, ensuring graceful shutdown when the underlying MCP server connection fails. The proxy now distinguishes between fatal connection errors (broken pipe, connection reset, unexpected EOF) and recoverable errors, returning a FatalError for the former case that includes an optional error response to send to the client before terminating.

Key changes:

  • Modified forward_request to return Result<Option<Message>, FatalError> instead of Option<Message>
  • Added is_fatal_io_error helper to classify I/O errors as fatal or recoverable
  • Updated error handling in jetsocat to detect fatal errors, send error responses, and exit gracefully

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/mcp-proxy/src/lib.rs Core logic changes: new FatalError type, modified forward_request signature to return Result, fatal error classification via is_fatal_io_error, and updated error handling for Process and NamedPipe transports
jetsocat/src/mcp.rs Updated to handle new Result return type from forward_request, sends error response on fatal errors and exits gracefully
testsuite/tests/mcp_proxy.rs Updated test assertions to unwrap the new outer Result layer from forward_request
testsuite/tests/cli/jetsocat.rs Added integration test mcp_proxy_terminated_on_broken_pipe to verify graceful shutdown behavior when MCP server connection breaks

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

@CBenoit CBenoit enabled auto-merge (squash) October 28, 2025 12:25
@CBenoit CBenoit merged commit d322206 into master Oct 29, 2025
38 checks passed
@CBenoit CBenoit deleted the DGW-313 branch October 29, 2025 11:26
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