
    ChM                        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J	r	  SSK
JrJrJr  SSKJrJr  SSKJrJr  SS	KJr  SS
KJr  \(       a  SSKJr  SSKJr  SSKJrJr   " S S\5      rg)z Resource template functionality.    )annotationsN)Callable)TYPE_CHECKINGAny)	BaseModelFieldvalidate_call)FunctionResourceResource)find_context_parameterinject_context)func_metadata)Icon)Context)ServerSessionT)LifespanContextTRequestTc                  V   \ rS rSr% Sr\" SS9rS\S'   \" SS9rS\S'   \" S	S
S9r	S\S'   \" SS9r
S\S'   \" SSS9rS\S'   \" S
SS9rS\S'   \" SS9rS\S'   \" SS9rS\S'   \" S
SS9rS\S'   \      S$                 S%S  jj5       rS&S! jr S'       S(S" jjrS#rg
))ResourceTemplate   z.A template for dynamically creating resources.z<URI template with parameters (e.g. weather://{city}/current))descriptionstruri_templatezName of the resourcenamez$Human-readable title of the resourceN)r   default
str | Nonetitlez%Description of what the resource doesr   
text/plainz!MIME type of the resource content)r   r   	mime_typez0Optional list of icons for the resource templatelist[Icon] | NoneiconsT)excludeCallable[..., Any]fnz#JSON schema for function parametersdict[str, Any]
parametersz-Name of the kwarg that should receive contextcontext_kwargc	                :   U=(       d    UR                   n	U	S:X  a  [        S5      eUc  [        U5      n[        UUb  U/O/ S9n
U
R                  R                  5       n[        U5      nU " UU	UU=(       d    UR                  =(       d    SU=(       d    SUUUUS9	$ )z"Create a template from a function.z<lambda>z,You must provide a name for lambda functions)
skip_names r   )	r   r   r   r   r   r!   r$   r&   r'   )__name__
ValueErrorr   r   	arg_modelmodel_json_schemar	   __doc__)clsr$   r   r   r   r   r   r!   r'   	func_namefunc_arg_metadatar&   s               `/home/james-whalen/.local/lib/python3.13/site-packages/mcp/server/fastmcp/resources/templates.pyfrom_functionResourceTemplate.from_function$   s     'BKK	
"KLL  226M **7*C
 '00BBD
 2%#7rzz7R/<!'

 
	
    c                    U R                   R                  SS5      R                  SS5      n[        R                  " SU S3U5      nU(       a  UR	                  5       $ g)z5Check if URI matches template and extract parameters.{z(?P<}z>[^/]+)^$N)r   replacerematch	groupdict)selfuripatternr>   s       r3   matchesResourceTemplate.matchesO   sT     ##++C8@@iP1WIQ-??$$r6   c           
       ^#     [        U R                  X#U R                  5      nU R                  " S0 UD6m[        R                  " T5      (       a
  TI Sh  vN m[        UU R                  U R                  U R                  U R                  U R                  U4S jS9$  NI! [         a  n[        SU 35      eSnAff = f7f)z>Create a resource from the template with the given parameters.Nc                    > T $ N )results   r3   <lambda>2ResourceTemplate.create_resource.<locals>.<lambda>o   s    6r6   )rA   r   r   r   r   r!   r$   z'Error creating resource from template: rH   )r   r$   r'   inspectiscoroutiner
   r   r   r   r   r!   	Exceptionr,   )r@   rA   paramscontexterI   s        @r3   create_resource ResourceTemplate.create_resourceX   s     	L#DGGVd>P>PQF WW&v&F""6**%#YYjj ,,..jj!  &  	LFqcJKK	Ls<   CAB$ B"AB$ !C"B$ $
C.B<<CCrH   )NNNNNN)r$   r#   r   r   r   r   r   r   r   r   r   r   r!   r    r'   r   returnr   )rA   r   rT   zdict[str, Any] | NonerG   )rA   r   rO   r%   rP   z:Context[ServerSessionT, LifespanContextT, RequestT] | NonerT   r   )r+   
__module____qualname____firstlineno__r/   r   r   __annotations__r   r   r   r   r!   r$   r&   r'   classmethodr4   rC   rR   __static_attributes__rH   r6   r3   r   r      sa   8*hiL#i"89D#9*PZ^_E:_#0WXKX<=`aIsa$T?qrEr"40B0!&3X!YJY %d8g hM:h
   "& $#'$((
(
 (
 	(

 (
  (
 (
 !(
 "(
 
(
 (
T OS	LL L L	L
 
L Lr6   r   ) r/   
__future__r   rL   r=   collections.abcr   typingr   r   pydanticr   r   r	   "mcp.server.fastmcp.resources.typesr
   r   .mcp.server.fastmcp.utilities.context_injectionr   r   *mcp.server.fastmcp.utilities.func_metadatar   	mcp.typesr   mcp.server.fastmcp.serverr   mcp.server.sessionr   mcp.shared.contextr   r   r   rH   r6   r3   <module>rf      sE    & "  	 $ % 4 4 I a D 11=[Ly [Lr6   