@@ -13,13 +13,15 @@ def __call__(
1313 headers : dict [str , str ] | None = None ,
1414 timeout : httpx .Timeout | None = None ,
1515 auth : httpx .Auth | None = None ,
16+ verify : bool | None = None ,
1617 ) -> httpx .AsyncClient : ...
1718
1819
1920def create_mcp_http_client (
2021 headers : dict [str , str ] | None = None ,
2122 timeout : httpx .Timeout | None = None ,
2223 auth : httpx .Auth | None = None ,
24+ verify : bool | None = None ,
2325) -> httpx .AsyncClient :
2426 """Create a standardized httpx AsyncClient with MCP defaults.
2527
@@ -32,6 +34,8 @@ def create_mcp_http_client(
3234 timeout: Request timeout as httpx.Timeout object.
3335 Defaults to 30 seconds if not specified.
3436 auth: Optional authentication handler.
37+ verify: Either True to use default CA bundle, False to disable verification, or an instance of ssl.SSLContext.
38+
3539
3640 Returns:
3741 Configured httpx.AsyncClient instance with MCP defaults.
@@ -60,6 +64,10 @@ def create_mcp_http_client(
6064 auth = BasicAuth(username="user", password="pass")
6165 async with create_mcp_http_client(headers, timeout, auth) as client:
6266 response = await client.get("/protected-endpoint")
67+
68+ # With SSL verification disabled
69+ async with create_mcp_http_client(verify=False) as client:
70+ response = await client.get("/insecure-endpoint")
6371 """
6472 # Set MCP defaults
6573 kwargs : dict [str , Any ] = {
@@ -80,4 +88,8 @@ def create_mcp_http_client(
8088 if auth is not None :
8189 kwargs ["auth" ] = auth
8290
91+ # Handle SSL verification
92+ if verify is not None :
93+ kwargs ["verify" ] = verify
94+
8395 return httpx .AsyncClient (** kwargs )
0 commit comments