|
38 | 38 | from typing import Any, cast |
39 | 39 | from urllib.parse import parse_qs, urlparse |
40 | 40 |
|
41 | | -import httpx |
| 41 | +import httpx2 |
42 | 42 | import mcp_types as types |
43 | 43 | from mcp_types.version import MODERN_PROTOCOL_VERSIONS |
44 | 44 | from pydantic import AnyUrl |
@@ -151,7 +151,7 @@ async def handle_redirect(self, authorization_url: str) -> None: |
151 | 151 | """Fetch the authorization URL and extract the auth code from the redirect.""" |
152 | 152 | logger.debug(f"Fetching authorization URL: {authorization_url}") |
153 | 153 |
|
154 | | - async with httpx.AsyncClient() as client: |
| 154 | + async with httpx2.AsyncClient() as client: |
155 | 155 | response = await client.get( |
156 | 156 | authorization_url, |
157 | 157 | follow_redirects=False, |
@@ -486,13 +486,13 @@ async def run_enterprise_managed_authorization(server_url: str) -> None: |
486 | 486 | # learn it from the harness's PRM document (RFC 9728); production |
487 | 487 | # deployments would supply it as static configuration instead. |
488 | 488 | prm_url = build_protected_resource_metadata_discovery_urls(None, server_url)[0] |
489 | | - async with httpx.AsyncClient(timeout=30.0) as http: |
| 489 | + async with httpx2.AsyncClient(timeout=30.0) as http: |
490 | 490 | prm = (await http.get(prm_url)).raise_for_status().json() |
491 | 491 | as_issuer = prm["authorization_servers"][0] |
492 | 492 |
|
493 | 493 | async def fetch_id_jag(audience: str, resource: str) -> str: |
494 | 494 | """Leg 1 - RFC 8693 token-exchange at the enterprise IdP.""" |
495 | | - async with httpx.AsyncClient(timeout=30.0) as http: |
| 495 | + async with httpx2.AsyncClient(timeout=30.0) as http: |
496 | 496 | resp = await http.post( |
497 | 497 | idp_token_endpoint, |
498 | 498 | data={ |
@@ -563,9 +563,9 @@ async def run_auth_code_client(server_url: str) -> None: |
563 | 563 | await _run_auth_session(server_url, oauth_auth) |
564 | 564 |
|
565 | 565 |
|
566 | | -async def _run_auth_session(server_url: str, oauth_auth: httpx.Auth) -> None: |
| 566 | +async def _run_auth_session(server_url: str, oauth_auth: httpx2.Auth) -> None: |
567 | 567 | """Common session logic for all OAuth flows.""" |
568 | | - http_client = httpx.AsyncClient(auth=oauth_auth, timeout=30.0) |
| 568 | + http_client = httpx2.AsyncClient(auth=oauth_auth, timeout=30.0) |
569 | 569 | transport = streamable_http_client(url=server_url, http_client=http_client) |
570 | 570 | async with Client(transport, mode=client_mode(), elicitation_callback=default_elicitation_callback) as client: |
571 | 571 | logger.debug("Initialized successfully") |
|
0 commit comments