
    )`i                    N    d Z ddlmZ ddlZddlZddlmZ ddlmZ dd
ZddZ	dS )z(Context injection utilities for FastMCP.    )annotationsN)Callable)AnyfnCallable[..., Any]return
str | Nonec                   ddl m} 	 t          j        |           }n# t          $ r Y dS w xY w|                                D ]\  }}t          j        |          rt          ||          r|c S t          j	        |          }|Ct          j
        |          }|D ],}t          j        |          rt          ||          r|c c S -dS )a#  Find the parameter that should receive the Context object.

    Searches through the function's signature to find a parameter
    with a Context type annotation.

    Args:
        fn: The function to inspect

    Returns:
        The name of the context parameter, or None if not found
    r   )ContextN)mcp.server.fastmcp.serverr   typingget_type_hints	Exceptionitemsinspectisclass
issubclass
get_originget_args)r   r   hints
param_name
annotationoriginargsargs           /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/mcp/server/fastmcp/utilities/context_injection.pyfind_context_parameterr      s    211111%b))   tt
 #(++-- & &
J?:&& 	:j'+J+J 	 ":..?:..D & &?3'' &JsG,D,D &%%%%%%4s    
++kwargsdict[str, Any]context
Any | Nonecontext_kwargc                    |
|i |||iS |S )aY  Inject context into function kwargs if needed.

    Args:
        fn: The function that will be called
        kwargs: The current keyword arguments
        context: The context object to inject (if any)
        context_kwarg: The name of the parameter to inject into

    Returns:
        Updated kwargs with context injected if applicable
     )r   r   r    r"   s       r   inject_contextr%   1   s)    "  W%81&1-111M    )r   r   r   r	   )
r   r   r   r   r    r!   r"   r	   r   r   )
__doc__
__future__r   r   r   collections.abcr   r   r   r%   r$   r&   r   <module>r*      s    . . " " " " " "   $ $ $ $ $ $      # # # #L     r&   