From 246bad582f7985cfc97af4a9c87fd9055b2f313e Mon Sep 17 00:00:00 2001 From: Yufeng He <40085740+he-yufeng@users.noreply.github.com> Date: Thu, 28 May 2026 05:22:05 +0800 Subject: [PATCH] fix: accept FastMCP HTTP factory kwargs --- pydantic_ai_slim/pydantic_ai/mcp.py | 1 + tests/test_mcp_toolset.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pydantic_ai_slim/pydantic_ai/mcp.py b/pydantic_ai_slim/pydantic_ai/mcp.py index be8797615c..e40b40e6d6 100644 --- a/pydantic_ai_slim/pydantic_ai/mcp.py +++ b/pydantic_ai_slim/pydantic_ai/mcp.py @@ -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 diff --git a/tests/test_mcp_toolset.py b/tests/test_mcp_toolset.py index 8eeac1839d..c8eb8dfd42 100644 --- a/tests/test_mcp_toolset.py +++ b/tests/test_mcp_toolset.py @@ -99,6 +99,8 @@ 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() @@ -106,6 +108,8 @@ def test_sse_url_with_http_client_uses_factory(self): 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