Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pydantic_ai_slim/pydantic_ai/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2771,6 +2771,7 @@ def factory(
headers: dict[str, str] | None = None,
timeout: httpx.Timeout | None = None,
auth: httpx.Auth | None = None,
**_kwargs: Any,
) -> httpx.AsyncClient:
return http_client

Expand Down
11 changes: 11 additions & 0 deletions tests/test_mcp_toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ def test_sse_url_with_http_client_uses_factory(self):
assert toolset.client.transport.httpx_client_factory is not None
assert toolset.client.transport.httpx_client_factory() is client

def test_http_client_factory_tolerates_extra_kwargs(self):
"""The factory returned by _make_httpx_client_factory must accept extra
kwargs (e.g. ``follow_redirects``) that FastMCP transports may pass."""
client = httpx.AsyncClient()
toolset = MCPToolset('https://example.com/mcp', http_client=client)
factory = toolset.client.transport.httpx_client_factory
assert factory is not None
# FastMCP's StreamableHttpTransport passes follow_redirects=
result = factory(follow_redirects=True)
assert result is client

def test_http_kwargs_with_non_url_input_raises(self):
"""HTTP-only kwargs (headers/auth/verify/http_client) must error out when the connection
target isn't an HTTP URL — otherwise the kwargs are silently dropped on stdio / Path /
Expand Down
Loading