
    Ch                    d    S r SSKJr  SSKrSSKrSSKJr  SSKJr  SS jr          S	S jr	g)
z(Context injection utilities for FastMCP.    )annotationsN)Callable)Anyc                   SSK Jn   [        R                  " U 5      nUR                  5        H  u  p4[        R                  " U5      (       a  [        XA5      (       a  Us  $ [        R                  " U5      nUc  MO  [        R                  " U5      nU H6  n[        R                  " U5      (       d  M   [        Xq5      (       d  M2  Us  s  $    M     g! [         a     gf = f)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)fnr   hints
param_name
annotationoriginargsargs           h/home/james-whalen/.local/lib/python3.13/site-packages/mcp/server/fastmcp/utilities/context_injection.pyfind_context_parameterr      s     2%%b) #(++-
??:&&:j+J+J "":.??:.D??3''Js,D,D%%  #0 %  s   C 
C! C!c                     Ub
  Ub  0 UEX20E$ U$ )a9  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   kwargscontextcontext_kwargs       r   inject_contextr    1   s$    "  W%81&1-11M    )r   Callable[..., Any]return
str | None)
r   r"   r   dict[str, Any]r   z
Any | Noner   r$   r#   r%   )
__doc__
__future__r   r   r	   collections.abcr   r   r   r    r   r!   r   <module>r)      sP    . "   $ #L  	
 r!   