Skip to content

Conversation

@CodeWithKyrian
Copy link
Contributor

This PR introduces PSR-17 factory auto-discovery to the StreamableHttpTransport, simplifying HTTP transport initialization by automatically discovering ResponseFactory and StreamFactory implementations.

Motivation & Context

The original implementation required developers to manually create and pass PSR-17 factory instances, adding unnecessary boilerplate to every HTTP transport usage. This was particularly cumbersome in simple use cases and examples where the choice of PSR-7 implementation wasn't critical. By implementing auto-discovery, we can provide a much cleaner API while still allowing explicit factory injection when needed.

What's Changed

  • Added php-http/discovery dependency for PSR-17 factory discovery
  • Made ResponseFactory and StreamFactory constructor parameters optional with fallback to auto discovery
  • Updated all HTTP examples to use the simplified API with Psr17Factory (from php-http/discovery)
  • Updated documentation to explain auto-discovery behavior and supported packages
  • Disabled automatic plugin installation for php-http/discovery

Breaking Changes

None. Existing code continues to work unchanged, and the simplified API is opt-in.

Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

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

Nice one - thanks! 👍

@chr-hertel chr-hertel merged commit 0963d24 into modelcontextprotocol:main Oct 26, 2025
10 checks passed
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.

2 participants