
    {h	
              	           d Z ddlmZmZ ddlZdgZ G d de      Z	 	 	 ddeeef   dz  dej                  dz  d	ej                  dz  d
ej                  fdZy)z@Utilities for creating standardized httpx AsyncClient instances.    )AnyProtocolNcreate_mcp_http_clientc            	           e Zd Z	 	 	 ddeeef   dz  dej                  dz  dej                  dz  dej                  fdZ	y)McpHttpClientFactoryNheaderstimeoutauthreturnc                      y )N )selfr   r	   r
   s       X/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/mcp/shared/_httpx_utils.py__call__zMcpHttpClientFactory.__call__   s    
      NNN)
__name__
__module____qualname__dictstrhttpxTimeoutAuthAsyncClientr   r   r   r   r   r   
   s]     *.(,"&	 c3h$&  %  jj4	 
 
		 r   r   r   r	   r
   r   c                     ddi}|t        j                  d      |d<   n||d<   | | |d<   |||d<   t        j                  di |S )a	  Create a standardized httpx AsyncClient with MCP defaults.

    This function provides common defaults used throughout the MCP codebase:
    - follow_redirects=True (always enabled)
    - Default timeout of 30 seconds if not specified

    Args:
        headers: Optional headers to include with all requests.
        timeout: Request timeout as httpx.Timeout object.
            Defaults to 30 seconds if not specified.
        auth: Optional authentication handler.

    Returns:
        Configured httpx.AsyncClient instance with MCP defaults.

    Note:
        The returned AsyncClient must be used as a context manager to ensure
        proper cleanup of connections.

    Examples:
        # Basic usage with MCP defaults
        async with create_mcp_http_client() as client:
            response = await client.get("https://api.example.com")

        # With custom headers
        headers = {"Authorization": "Bearer token"}
        async with create_mcp_http_client(headers) as client:
            response = await client.get("/endpoint")

        # With both custom headers and timeout
        timeout = httpx.Timeout(60.0, read=300.0)
        async with create_mcp_http_client(headers, timeout) as client:
            response = await client.get("/long-request")

        # With authentication
        from httpx import BasicAuth
        auth = BasicAuth(username="user", password="pass")
        async with create_mcp_http_client(headers, timeout, auth) as client:
            response = await client.get("/protected-endpoint")
    follow_redirectsTg      >@r	   r   r
   r   )r   r   r   )r   r	   r
   kwargss       r   r   r      sl    ^ 	DF
 !MM$/y#y #y v&v&&r   r   )__doc__typingr   r   r   __all__r   r   r   r   r   r   r   r   r   r   <module>r"      s    F   #
$ 8   &*$("@'#s(^d"@']]T!@' **t
@' 	@'r   