Skip to content

Conversation

@camilleislasse
Copy link
Contributor

The Protocol keeps a reference to the transport but never resets it after a request. In worker mode, the same Protocol instance is reused across requests, causing "Protocol already connected to a transport" error on subsequent requests.

Add Protocol::disconnect() to reset the transport reference, called in Server::run()'s finally block after transport->close().

Motivation and Context

Fixes #999

How Has This Been Tested?

  • Reproduced the issue with FrankenPHP worker mode (symfony/ai demo app)
  • Verified fix works (multiple sequential requests succeed)
  • Added unit tests for worker mode scenario

Breaking Changes

None

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

The Protocol keeps a reference to the transport but never resets it
after a request. In worker mode (FrankenPHP, RoadRunner), the same
Protocol instance is reused across requests, causing "Protocol already
connected to a transport" error on subsequent requests.

Add Protocol::disconnect() to reset the transport reference, called
in Server::run()'s finally block after transport->close().

Fixes symfony/ai#999
@lvluoyue
Copy link
Contributor

Hello, I submitted a similar PR #160 , but he removed the reference to transport, thus achieving the ability to handle multiple transports simultaneously. Is this useful for you?

@camilleislasse
Copy link
Contributor Author

Hello, I submitted a similar PR #160 , but he removed the reference to transport, thus achieving the ability to handle multiple transports simultaneously. Is this useful for you?

I tested your PR with FrankenPHP worker mode and it works perfectly. Your approach is cleaner - removing the transport reference entirely is better than resetting it. I'll close my PR in favor of yours.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MCP Bundle] Incompatibility of the MCPBundle with FrankenPHP

2 participants