+
    Q(iD                    x   R t ^ RIHt ^ RIt^ RIHt ^ RIHt ^ RI	H
t
HtHt ^ RIt^ RIHt ^ RIt^ RIHt ^ RIHt ] ! R R	4      4       t] ! R
 R4      4       t] ! R R4      4       t] ! R R4      4       t] ! R R4      4       tR R ltR R ltR R lt ! R R]]4      tR R ltR R ltR R R llt R# )!z+Utilities for inspecting FastMCP instances.)annotationsN)	dataclass)Enum)AnyLiteralcast)FastMCP)Clientc                      ] tR t^t$ RtR]R&   R]R&   R]R&   R]R&   R	tR
]R&   R	tR
]R&   R	tR]R&   R	t	R]R&   R	t
R]R&   R	tR
]R&   RtR	# )ToolInfozInformation about a tool.strkeyname
str | Nonedescriptiondict[str, Any]input_schemaNdict[str, Any] | Noneoutput_schemar   list[str] | Nonetagstitlelist[dict[str, Any]] | Noneiconsmeta )__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   r   r   r   __static_attributes__r       _/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/utilities/inspect.pyr   r      s\    #	H
I  +/M(/)-K&-!D
!E:)-E&-"&D
&r#   r   c                      ] tR t^"t$ RtR]R&   R]R&   R]R&   RtR]R	&   RtR
]R&   RtR]R&   Rt	R]R&   Rt
R]R&   RtR# )
PromptInfozInformation about a prompt.r   r   r   r   r   Nr   	argumentsr   r   r   r   r   r   r   )r   r   r   r   r    r!   r'   r   r   r   r   r"   r   r#   r$   r&   r&   "   sK    %	H
I-1I*1!D
!E:)-E&-"&D
&r#   r&   c                      ] tR t^0t$ RtR]R&   R]R&   R]R&   R]R&   RtR]R	&   RtR
]R&   RtR]R&   Rt	R]R&   Rt
R]R&   RtR
]R&   RtR# )ResourceInfozInformation about a resource.r   r   urir   r   r   N	mime_typer   r   r   r   r   r   r   r   r   )r   r   r   r   r    r!   r+   r   r   r   r   r   r"   r   r#   r$   r)   r)   0   s[    '	H	H
 Iz )-K&-!D
!E:)-E&-"&D
&r#   r)   c                      ] tR t^@t$ RtR]R&   R]R&   R]R&   R]R&   RtR]R	&   RtR
]R&   RtR
]R&   Rt	R]R&   Rt
R]R&   RtR]R&   RtR
]R&   RtR# )TemplateInfoz&Information about a resource template.r   r   uri_templater   r   r   Nr+   r   
parametersr   r   r   r   r   r   r   r   )r   r   r   r   r    r!   r+   r/   r   r   r   r   r   r"   r   r#   r$   r-   r-   @   sg    0	H
 Iz (,J%,)-K&-!D
!E:)-E&-"&D
&r#   r-   c                      ] tR t^Qt$ RtR]R&   R]R&   R]R&   R]R&   R]R	&   R]R
&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   RtR# )FastMCPInfoz.Information extracted from a FastMCP instance.r   r   r   instructionsversionwebsite_urlr   r   fastmcp_versionmcp_versionintserver_generationzlist[ToolInfo]toolszlist[PromptInfo]promptszlist[ResourceInfo]	resourceszlist[TemplateInfo]	templatesr   capabilitiesr   N)r   r   r   r   r    r!   r"   r   r#   r$   r1   r1   Q   sR    8
I&&!!!!  r#   r1   c                    V ^8  d   QhRRRR/# )   mcpzFastMCP[Any]returnr1   r   )formats   "r$   __annotate__rC   d   s     E E, E; Er#   c                  "   V P                  4       G Rj  xL
 pV P                  4       G Rj  xL
 pV P                  4       G Rj  xL
 pV P                  4       G Rj  xL
 p. pV EF@  pVP	                  VP
                  R7      pTP                  \        VP                  VP
                  ;'       g    VP                  VP                  VP                  '       d   VP                  M/ VP                  VP                  '       d   VP                  P                  4       MRVP                  '       d   \        VP                  4      MRVP                   VP"                  '       d*   VP"                   Uu. uF  qP                  4       NK  	  upMRVP$                  R7
      4       EKC  	  . p	V EF	  p
T	P                  \'        V
P                  V
P
                  ;'       g    V
P                  V
P                  V
P(                  '       d*   V
P(                   Uu. uF  qP                  4       NK  	  upMRV
P                  '       d   \        V
P                  4      MRV
P                   V
P"                  '       d*   V
P"                   Uu. uF  qP                  4       NK  	  upMRV
P$                  R7      4       EK  	  . pV EF  pTP                  \+        VP                  \-        VP.                  4      VP
                  VP                  VP0                  VP                  '       d   VP                  P                  4       MRVP                  '       d   \        VP                  4      MRVP                   VP"                  '       d*   VP"                   Uu. uF  qP                  4       NK  	  upMRVP$                  R7
      4       EK  	  . pV EF  pTP                  \3        VP                  VP4                  VP
                  VP                  VP0                  VP6                  VP                  '       d   VP                  P                  4       MRVP                  '       d   \        VP                  4      MRVP                   VP"                  '       d*   VP"                   Uu. uF  qP                  4       NK  	  upMRVP$                  R7      4       EK
  	  RRR	/R
RRRR/RRR/R/ /p\9        V P:                  R4      '       dP   V P:                  P"                  '       d4   V P:                  P"                   Uu. uF  qP                  4       NK  	  upMRp\9        V P:                  R4      '       d   V P:                  P<                  MRp\?        V P
                  V P@                  \9        V R4      '       d   V PB                  MV P:                  PB                  VV\D        PF                  \H        PJ                  PC                  R4      ^VV	VVVR7      #  EL EL EL ELu upi u upi u upi u upi u upi u upi 5i)zExtract information from a FastMCP v2.x instance.

Args:
    mcp: The FastMCP v2.x instance to inspect

Returns:
    FastMCPInfo dataclass containing the extracted information
N)r   
r   r   r   r   r   r   r   r   r   r   r   r   r   r'   r   r   r   r   
r   r*   r   r   r+   r   r   r   r   r   r   r.   r   r   r+   r/   r   r   r   r   r   r9   listChangedTr;   	subscribeFr:   loggingr   r4   r3   r@   r   r2   r3   r4   r   r5   r6   r8   r9   r:   r;   r<   r=   )&
list_toolslist_promptslist_resourceslist_resource_templatesto_mcp_toolr   appendr   r   r   inputSchemar   r   
model_dumpr   listr   r   r   r&   r'   r)   r   r*   r+   r-   r.   r/   hasattr_mcp_serverr4   r1   r2   r3   fastmcp__version__	importlibmetadata)r@   
tools_listprompts_listresources_listtemplates_list
tool_infostoolmcp_tooliconprompt_infospromptargresource_infosresourcetemplate_infostemplater=   server_iconsserver_website_urls   &                  r$   inspect_fastmcp_v2rm   d   s     ~~''J))++L--//N6688N J###3HHYY**$(( ,,5=5I5I5IX11r"00=A=M=M=MD,,779SW(,			T$))_tjj::: 6:ZZ@ZT(Z@YY	
 ( LJJ[[..FJJ"..### 8>7G7GH7G>>+7GH*0+++T&++&4ll<<< 6<\\B\T(\B[[	
 & N"LL%]]$00",,''' %00;;=,4MMMT(--(tnn>>> 6>^^D^T(^D]]	
 #* N"LL%22]]$00",,#..''' %00;;=,4MMMT(--(tnn>>> 6>^^D^T(^D]]	
 #. 	-&k5-?M5)2	L 3??G,,1F1F1F (+'<'<='<t	'<=  (/s'N'N##TX  XX%% 'Y 7 7S__=T=T&++&&..u5  ! [ (+/8  A I
 C, E. E" 	>s   YXYXYXYX!AY5(Y)Y,Y52Y(Y6X$AY"(YYX)1Y2Y:YX. B4Y2YYX3.B6Y%2YY&X8 >A'Y&Y>X=CYYY!Y$Yc                    V ^8  d   QhRRRR/# )r?   r@   	FastMCP1xrA   r1   r   )rB   s   "r$   rC   rC      s     K
 K
) K
 K
r#   c                R
  "   \        V 4      ;_uu_4       GRj  xL
 pVP                  4       G Rj  xL
 pVP                  4       G Rj  xL
 pVP                  4       G Rj  xL
 p VP	                  4       G Rj  xL
 p. pV F  pTP                  \        VP                  VP                  VP                  VP                  '       d   VP                  M/ RRRR\        VR4      '       d<   VP                  '       d*   VP                   Uu. uF  qP                  4       NK  	  upMRRR7
      4       K  	  . p	V F  p
Rp\        V
R4      '       d;   V
P                  '       d)   V
P                   Uu. uF  qP                  4       NK  	  ppT	P                  \        V
P                  V
P                  V
P                  TRR\        V
R4      '       d<   V
P                  '       d*   V
P                   Uu. uF  qP                  4       NK  	  upMRRR7      4       K  	  . pV F  pTP                  \!        \#        VP$                  4      \#        VP$                  4      VP                  VP                  VP&                  RRR\        VR4      '       d<   VP                  '       d*   VP                   Uu. uF  qP                  4       NK  	  upMRRR7
      4       K  	  . pV F  pTP                  \)        \#        VP*                  4      \#        VP*                  4      VP                  VP                  VP&                  RRRR\        VR4      '       d<   VP                  '       d*   VP                   Uu. uF  qP                  4       NK  	  upMRRR7      4       K  	  RR	R
/RRRR	R/RR	R/R/ /pVP,                  P.                  p\        VR4      '       d<   VP                  '       d*   VP                   Uu. uF  qP                  4       NK  	  upMRp\        VR4      '       d   VP0                  MRp\3        V P4                  P                  V P4                  P6                  V P4                  P8                  VV\:        P<                  \>        P@                  P9                  R4      ^VV	VVVR7      uuRRR4      GRj  xL
  #  EL EL EL ELn ELX  \
         d    . p ELfi ; iu upi u upi u upi u upi u upi u upi  LF  + GRj  xL 
 '       g   i     R# ; i5i)zExtract information from a FastMCP v1.x instance using a Client.

Args:
    mcp: The FastMCP v1.x instance to inspect

Returns:
    FastMCPInfo dataclass containing the extracted information
Nr   rE   r'   rF   rG   rH   r9   rI   Tr;   rJ   Fr:   rK   
websiteUrlr@   rL   )!r	   rM   rN   rO   rP   	ExceptionrR   r   r   r   rS   rV   r   rT   r'   r&   r)   r   r*   mimeTyper-   uriTemplateinitialize_result
serverInforq   r1   rW   r2   r3   rX   rY   rZ   r[   )r@   client	mcp_toolsmcp_promptsmcp_resourcesmcp_templatesr`   rb   rc   rd   
mcp_promptr'   rf   rg   mcp_resourceri   mcp_templater=   server_infork   rl   s   &                    r$   inspect_fastmcp_v1r      sr     c{{{f ++--	"//11$3355	"("@"@"BBM
 
!H ! ( 4 49A9M9M9M!5!5SU"& $x11hnnn :BH??,H "& %JIz;//J4H4H4H9C9M9MN9M#^^-9M	N"# * 6 6'z733
8H8H8H :D9I9IJ9I??,9IJ &, )L!!L,,-L,,-%** , 8 8*33 $|W55,:L:L:L :F9K9KL9K??,9KL *& )L!!L445!$\%=%=!>%** , 8 8*33# $|W55,:L:L:L :F9K9KL9K??,9KL ** mT*+umUCu-r	
 ..99 {G,,1B1B1B ,7+<+<=+<4__+<= 	 '.k<&H&HK""d 	 %%55OO++*#//!**2259 $$%
g {{-15 C 	M	  I O K( M* M$ >W {{{s&  T'ST'T
S
T

ST
"S#T
(S;S<S A>T
?T
S*"%?T
%T
3S/
AT
%T
3S4BT
%T
3S9"BT
&T
4S>$AT
+T
9TB#T
4T'TT'
T
T
T
SS'#T
&S''!T
T'
T$	T
T$	T$		T'c                    V ^8  d   QhRRRR/# )r?   r@   FastMCP[Any] | FastMCP1xrA   r1   r   )rB   s   "r$   rC   rC   z  s     A A7 AK Ar#   c                   "   \        V \        4      '       d   \        V 4      G Rj  xL
 # \        \	        \
        \        ,          V 4      4      G Rj  xL
 #  L0 L5i)aD  Extract information from a FastMCP instance into a dataclass.

This function automatically detects whether the instance is FastMCP v1.x or v2.x
and uses the appropriate extraction method.

Args:
    mcp: The FastMCP instance to inspect (v1.x or v2.x)

Returns:
    FastMCPInfo dataclass containing the extracted information
N)
isinstancero   r   rm   r   r   r   )r@   s   &r$   inspect_fastmcpr   z  sC      #y!!',,,'WS\3(?@@@ -@s!   %AA+AAAAc                  "    ] tR tRtRtRtRtRtR# )InspectFormati  z"Output format for inspect command.rX   r@   r   N)r   r   r   r   r    FASTMCPMCPr"   r   r#   r$   r   r     s    ,G
Cr#   r   c                    V ^8  d   QhRRRR/# )r?   infor1   rA   bytesr   )rB   s   "r$   rC   rC     s     3 3k 3e 3r#   c                v   RRV P                   RV P                  RV P                  RV P                  RV P                  RV P
                  RV P                  /R	R
V P                  RV P                  /RV P                  RV P                  RV P                  RV P                  /p\        P                  ! V^R7      # )zzFormat FastMCPInfo as FastMCP-specific JSON.

This includes FastMCP-specific fields like tags, enabled, annotations, etc.
serverr   r2   r3   r4   r   
generationr=   environmentrX   r@   r9   r:   r;   r<   indent)r   r2   r3   r4   r   r8   r=   r5   r6   r9   r:   r;   r<   pydantic_coreto_json)r   results   & r$   format_fastmcp_infor     s     	DIID--t||4++TZZ$00D--
 	t++4##
 	4<<T^^T^^#F(   22r#   c                    V ^8  d   QhRRRR/# )r?   r@   r   rA   r   r   )rB   s   "r$   rC   rC     s     7 77 7E 7r#   c                  "   \        V 4      ;_uu_4       GRj  xL
 pVP                  4       G Rj  xL
 pVP                  4       G Rj  xL
 pVP                  4       G Rj  xL
 pVP	                  4       G Rj  xL
 pVP
                  P                  pRR\        P                  R\        P                  P                  R4      /RVR/ RVP                  RVP                  R	VP                  R
VP                  /p\         P"                  ! V^R7      uuRRR4      GRj  xL
  #  EL L L L L L  + GRj  xL 
 '       g   i     R# ; i5i)zFormat server info as standard MCP protocol JSON.

Uses Client to get the standard MCP protocol format with camelCase fields.
Includes version metadata at the top level.
Nr   rX   r@   rv   r=   r9   r:   r;   resourceTemplatesr   )r	   list_tools_mcplist_prompts_mcplist_resources_mcplist_resource_templates_mcpru   rv   rX   rY   rZ   r[   r3   r9   r:   r;   r   r   r   )r@   rw   tools_resultprompts_resultresources_resulttemplates_resultr   r   s   &       r$   format_mcp_infor     s     c{{{f#2244%6688!'!:!:!<<!'!C!C!EE ..99 7..y))11%8 +B\''~--)33!1!C!C
 $$VA61 {{48<E {{{s   ED&ED3D)D3
D+D3"D-#D3:D/;BD3E D1!E)D3+D3-D3/D31E3E	9D<:
E	E		Ec               (    V ^8  d   QhRRRRRRRR/# )	r?   r@   r   rB   z)InspectFormat | Literal['fastmcp', 'mcp']r   zFastMCPInfo | NonerA   r   r   )rB   s   "r$   rC   rC     s0     6 6	!656 6 	6r#   c                .  "   \        V\        4      '       d   \        V4      pV\        P                  8X  d   \	        V 4      G Rj  xL
 # V\        P
                  8X  d#   Vf   \        V 4      G Rj  xL
 p\        V4      # \        RV 24      h LI L5i)a  Format server information according to the specified format.

Args:
    mcp: The FastMCP instance
    format: Output format ("fastmcp" or "mcp")
    info: Pre-extracted FastMCPInfo (optional, will be extracted if not provided)

Returns:
    JSON bytes in the requested format
NzUnknown format: )	r   r   r   r   r   r   r   r   
ValueError)r@   rB   r   s   &&&r$   format_infor     s       &#v&"""$S)))	=((	( <(--D"4((+F8455 *
 .s$   ABB+B3B4BB)N)!r    
__future__r   importlib.metadatarZ   dataclassesr   enumr   typingr   r   r   r   mcp.server.fastmcpr   ro   rX   r	   fastmcp.server.serverr   r&   r)   r-   r1   rm   r   r   r   r   r   r   r   r   r#   r$   <module>r      s    1 "  !  % %  3   ) ' ' ' 
' 
' 
' ' ' ' ' ' '  ! ! !$EPK
\A$C 3:7B6 6r#   