Skip to content
Open
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
4 changes: 4 additions & 0 deletions tests/test_mcp_toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ def test_http_client_kwarg_uses_factory(self):
assert isinstance(toolset.client.transport, StreamableHttpTransport)
assert toolset.client.transport.httpx_client_factory is not None
assert toolset.client.transport.httpx_client_factory() is client
factory: Any = toolset.client.transport.httpx_client_factory
assert factory(follow_redirects=True) is client

def test_sse_url_with_http_client_uses_factory(self):
client = httpx.AsyncClient()
toolset = MCPToolset('https://example.com/sse', http_client=client)
assert isinstance(toolset.client.transport, SSETransport)
assert toolset.client.transport.httpx_client_factory is not None
assert toolset.client.transport.httpx_client_factory() is client
factory: Any = toolset.client.transport.httpx_client_factory
assert factory(follow_redirects=True) 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
Expand Down
Loading