Skip to content

feat(mcp): expose auth and httpx_client_factory in SSE/StreamableHttp params#2713

Merged
seratch merged 2 commits intoopenai:mainfrom
adityasingh2400:feat/sse-params-parity
Mar 19, 2026
Merged

feat(mcp): expose auth and httpx_client_factory in SSE/StreamableHttp params#2713
seratch merged 2 commits intoopenai:mainfrom
adityasingh2400:feat/sse-params-parity

Conversation

@adityasingh2400
Copy link
Contributor

Closes #2712

Summary

Adds missing transport-level parameters to MCPServerSseParams and MCPServerStreamableHttpParams, bringing both in line with what the underlying MCP SDK clients already support.

Param MCPServerSseParams MCPServerStreamableHttpParams
auth ✅ added ✅ added
httpx_client_factory ✅ added already present

Also refactors MCPServerStreamableHttp.create_streams() to use a kwargs dict (matching the new SSE pattern), eliminating the if httpx_client_factory / else branch.

Changes

  • src/agents/mcp/server.py: add auth + httpx_client_factory to MCPServerSseParams, wire through MCPServerSse.create_streams(); add auth to MCPServerStreamableHttpParams, refactor create_streams()
  • tests/mcp/test_mcp_auth_params.py: 7 new tests covering all new param combinations for both server types

Motivation

The underlying sse_client and streamablehttp_client functions already accept auth: httpx.Auth | None and httpx_client_factory. Without exposing them in the TypedDicts, users are forced to subclass just to pass standard httpx auth (OAuth token refresh, BasicAuth, custom cert chains, proxies).

… params

MCPServerSseParams was missing both auth and httpx_client_factory even though
the underlying sse_client supports them. MCPServerStreamableHttpParams was
missing auth even though streamablehttp_client supports it.

Changes:
- Add auth: NotRequired[httpx.Auth | None] to MCPServerSseParams
- Add httpx_client_factory: NotRequired[HttpClientFactory] to MCPServerSseParams
- Add auth: NotRequired[httpx.Auth | None] to MCPServerStreamableHttpParams
- Wire all three through their create_streams() implementations
- Refactor MCPServerStreamableHttp.create_streams() to use kwargs dict
  (eliminates the if/else branch, matching the SSE pattern)

This allows users to pass OAuth token-refresh handlers, custom SSL certs,
proxies, and other httpx-level authentication/transport config without
having to resort to custom subclasses.
@github-actions github-actions bot added enhancement New feature or request feature:mcp labels Mar 19, 2026
@seratch seratch added this to the 0.12.x milestone Mar 19, 2026
@seratch seratch merged commit 1bb5ff6 into openai:main Mar 19, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature:mcp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mcp): MCPServerSseParams missing auth and httpx_client_factory; MCPServerStreamableHttpParams missing auth

2 participants