Skip to content

[MCP] Allow Custom httpx_client_factory in MCPServerStreamableHttp #1829

@jjcampana

Description

@jjcampana

Summary

Add support for custom httpx_client_factory parameter in MCPServerStreamableHttp to allow users to configure custom HTTP client behavior for MCP StreamableHTTP connections.

Motivation

The underlying streamablehttp_client function from the MCP library already supports an httpx_client_factory parameter, but the MCPServerStreamableHttp class in the agents library doesn't expose this functionality. This limits users' ability to configure custom HTTP client settings (e.g., custom SSL certificates, proxy settings, custom retry logic).

Proposed Solution

  1. Extend MCPServerStreamableHttpParams to include an optional httpx_client_factory parameter
  2. Update MCPServerStreamableHttp.init to accept and store the custom factory
  3. Modify create_streams() to pass the custom factory to streamablehttp_client

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions