
    KiZ              	           d Z ddlmZmZ ddlZg dZdZd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_clientMCP_DEFAULT_TIMEOUTMCP_DEFAULT_SSE_READ_TIMEOUTg      >@g     r@c            	           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       c/home/jay/workspace/scripts/.codegraph-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                  t        t              |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_redirectsT)readr   r
   r   r   )r   r   r   r   r   )r
   r   r   kwargss       r   r   r      sp    ^ 	DF
 !MM*=D`ay#y #y v&v&&r   r   )__doc__typingr   r   r   __all__r   r   r	   r   r   r   r   r   r   r   r   r   <module>r%      s    F   
[  $  8   &*$("@'#s(^d"@']]T!@' **t
@' 	@'r   