+
    Q(i                       a  RS t<0 t R t^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
Ht ^ RIt^ RIt^ RIHt ^ RIHtHtHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RI H!t! ^ RI"H#t# ]#! R4      t$]! 4       t%RRRRRRRRRRRRRR/t&] ^ k RRRR/R R llt'R  R! lt(R" R# lt)R$ R% lt*R& R' lt+R(RR)R/R* R+ llt,R, R- lt-R. R/ lt.R0 R1 lt/R2 R3 lt0R4 R5 lt1R6 R7 lt2R8 R9 lt3R: R; lt4R< R= lt5R> R? lt6R@ RA lt7RB RC lt8RTRRRRRDRERFRERGRERHRERIRER(RR)R/	RJ RK lllt9RURRRRRLRERMRRIRER(RR)R/RN RO lllt:RPRRIRE/RQ RR llt;R# )Vz?Client-side CLI commands for querying and invoking MCP servers.N)Path)	AnnotatedAnyLiteral)Console)DiscoveredServerdiscover_serversresolve_name)CallToolResultClient)ElicitResult)ClientTransport)StreamableHttpTransport)SSETransport)StdioTransport)
get_loggerz
cli.clientstringstrintegerintnumberfloatbooleanboolarraylistobjectdictnullNonecommand	transportc                    V ^8  d   QhR\         R,          R\         R,          R\         R,          R\         \        \         \        3,          ,          \        ,          /# )   server_specNr    r!   return)r   r   r   r   )formats   "X/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/cli/client.py__annotate__r(   *   sV     E EtE 4ZE Tz	E
 	4S>O+E    c                  Ve0   V e,   \         P                  R4       \        P                  ! ^4       Ve   \	        V4      # V f,   \         P                  R4       \        P                  ! ^4       \        V \        4      '       g   Q hT pVP                  R4      '       dH   VR8X  d?   VP                  R4      P                  R4      '       g   VP                  R4      R,           pV# \        V4      pVP                  4       ;'       g/    VP                  4       '       * ;'       d    VP                  R4      pV'       de   VP                  R4      '       d   \        V4      # VP                  R4      '       d*   VP                  4       p\        R	R
\        V4      R.R7      # V#  \!        V4      #   \"         d:   p\         P                  RT 24       \        P                  ! ^4        Rp?R# Rp?ii ; i)uJ  Turn CLI inputs into something ``Client()`` accepts.

Exactly one of ``server_spec`` or ``command`` should be provided.

Resolution order for ``server_spec``:
1. URLs (``http://``, ``https://``) — passed through as-is.
   If ``--transport`` is ``sse``, the URL is rewritten to end with ``/sse``
   so ``infer_transport`` picks the right transport.
2. Existing file paths, or strings ending in ``.py``/``.js``/``.json``.
3. Anything else — name-based resolution via ``resolve_name``.

When ``command`` is provided, the string is shell-split into a
``StdioTransport(command, args)``.
NzG[bold red]Error:[/bold red] Cannot use both a server spec and --commandzB[bold red]Error:[/bold red] Provide a server spec or use --commandsse/z/sse.py.jsonfastmcprunz--no-bannerr    args[bold red]Error:[/bold red] zhttp://zhttps://)r-   z.jsr.   )consoleprintsysexit_build_stdio_from_command
isinstancer   
startswithrstripendswithr   is_fileis_dir_resolve_json_specresolver   r	   
ValueError)r$   r    r!   specpathr>   resolved_pathexcs   &$$     r'   resolve_server_specrG   *   s   * {6U	
 	(11P	
 	k3''''D .//dkk#&6&?&?&G&G;;s#f,D :Dlln  KKMDDdmm,CD  ==!!%d++== LLNM!!S/? 
 D!! 4SE:;s   (
F3 3G7>.G22G7c                0    V ^8  d   QhR\         R\        /# )r#   command_strr%   )r   r   )r&   s   "r'   r(   r(   r   s     < <3 <> <r)   c                X    \         P                  ! V 4      pX'       g,   \        P	                  R4       \
        P                  ! ^4       \        V^ ,          VR,          R7      #   \         d9   p\        P	                  RT 24       \
        P                  ! ^4        Rp?LRp?ii ; i)z7Shell-split a command string into a ``StdioTransport``.z-[bold red]Error:[/bold red] Invalid command: Nz+[bold red]Error:[/bold red] Empty --command:   NNr1   )shlexsplitrB   r5   r6   r7   r8   r   )rI   partsrF   s   &  r'   r9   r9   r   sz    K(
 CD%(r;;  EcUKLs   A& &B)1.B$$B)c                h    V ^8  d   QhR\         R\        \        \        \        3,          ,          /# )r#   rD   r%   )r   r   r   r   )r&   s   "r'   r(   r(      s'      T cDcN&: r)   c                "   V P                  4       '       g0   \        P                  RV  R24       \        P                  ! ^4        \
        P                  ! V P                  4       4      p\        X\        4      '       d
   RV9   d   V# \        P                  RV  RV  R	24       \        P                  ! ^4       R#   \
        P                   d<   p\        P                  RT  RT 24       \        P                  ! ^4        Rp?LRp?ii ; i)
z%Disambiguate a ``.json`` server spec.z2[bold red]Error:[/bold red] File not found: [cyan][/cyan]z,[bold red]Error:[/bold red] Invalid JSON in : N
mcpServersz"[bold red]Error:[/bold red] [cyan]zl[/cyan] is a FastMCP server config, not an MCPConfig.
Start the server first, then query it:

  fastmcp run z*
  fastmcp list http://localhost:8000/mcp
)existsr5   r6   r7   r8   jsonloads	read_textJSONDecodeErrorr:   r   )rD   datarF   s   &  r'   r@   r@      s     ;;==@gN	
 	zz$..*+
 $,$"6 MM
,TF 3 5	6 HHQK  DTF"SERSs   $B> >D1D		Dc                ~    V ^8  d   QhR\         \        \         \        3,          ,          \        ,          R\        /# )r#   resolvedr%   )r   r   r   r   r   )r&   s   "r'   r(   r(      s0     I IcDcN2_D I Ir)   c                |    \        V \        4      '       d   V P                  R4      # \        V \        \        34      # )zReturn True if the resolved target will use an HTTP-based transport.

MCPConfig dicts are excluded because ``MCPConfigTransport`` manages
individual server transports internally and does not support top-level auth.
r4   )r:   r   r;   r   r   )r[   s   &r'   _is_http_targetr]      s6     (C  ""#:;;h!8, GHHr)   c                    V ^8  d   QhR\         R\        \        ,          R,          R\        R\        R\        \        \         \        3,          ,          /# )r#   messageresponse_typeNparamscontextr%   )r   typer   r   r   )r&   s   "r'   r(   r(      sP     89 89899t#89 89 	89
 $sCx.!89r)   c                  "   ^ RI Hp \        P                  RV  24       \	        W$4      '       g   \        P                  R4      pVP                  4       P                  4       R8X  d   \        RR7      # VP                  4       P                  4       R8X  d   \        RR7      # \        R/ R7      # VP                  pVP                  R	/ 4      p\        VP                  R
. 4      4      pV'       g   \        P                  R4      pVP                  4       P                  4       R8X  d   \        RR7      # VP                  4       P                  4       R8X  d   \        RR7      # \        R/ R7      # / p	VP                  4        F  w  rVP                  RR4      pW9   d   RMRpRV
 RV RV R2p\        P                  V4      pVP                  4       P                  4       R8X  d   \        RR7      u # VP                  4       P                  4       R8X  d   \        RR7      u # VR8X  d	   W9  d   K  \        W4      W&   K  	  \        RV	R7      # 5i)zPrompt the user on the terminal for elicitation responses.

Prints the server's message and prompts for each field in the schema.
The user can type 'decline' or 'cancel' instead of a value to abort.
)ElicitRequestFormParamsz)
[bold yellow]Server asks:[/bold yellow] z7[dim](press Enter to accept, or type 'decline'):[/dim] decline)actioncancelaccept)rg   content
propertiesrequiredrc   r   z [red]*[/red]   [cyan]z	[/cyan] ()rR   )	mcp.typesre   r5   r6   r:   inputstriplowerr   requestedSchemagetsetitemscoerce_value)r_   r`   ra   rb   re   answerschemark   rl   result
field_namefield_schema	type_hint
req_markerprompt_textraws   &&&&            r'   _terminal_elicitation_handlerr      s     2MM>wiHIf66E
 <<>!Y.y11<<>!X-x008R88##FL"-J6::j"-.HE
 <<>!Y.y11<<>!X-x008R88F$.$4$4$6 
 $$VX6	(2(>_B
 Ii[*RPmmK(99;)+y1199;(*x00"93)#< %7  x88s   IItimeoutauthc                    V ^8  d   QhR\         \        \         \        3,          ,          \        ,          R\        R,          R\         R,          R\
        /# )r#   r[   r   Nr   r%   )r   r   r   r   r   r   )r&   s   "r'   r(   r(      sL      DcN"_4 T\ *	
 r)   c               v    VR8X  d   RpMVe   TpM\        V 4      '       d   RpMRp\        V VV\        R7      # )a  Build a ``Client`` from a resolved server spec.

Applies ``auth='oauth'`` automatically for HTTP-based targets unless
the caller explicitly passes ``--auth none`` to disable it.

``auth=None`` means "not specified" (use default), ``auth="none"``
means "explicitly disabled".
noneNoauth)r   r   elicitation_handler)r]   r   r   )r[   r   r   effective_auths   &$$ r'   _build_clientr      sI     v~%)				"	" 9	 r)   c                ^    V ^8  d   QhR\         R\        \         \        3,          R\        /# )r#   r   rz   r%   r   r   r   )r&   s   "r'   r(   r(     s)      c 4S> c r)   c                   VP                  RR4      pVR8X  d    \        V 4      # VR8X  d    \        V 4      # VR8X  d>   V P	                  4       R9   d   R	# V P	                  4       R9   d   R
# \        RV : 24      hVR9   d    \
        P                  ! V 4      # V #   \         d    \        RT : 24      Rhi ; i  \         d    \        RT : 24      Rhi ; i  \
        P                   d    \        RT RT : 24      Rhi ; i)z?Coerce a string CLI value according to a JSON-Schema type hint.rc   r   r   zExpected integer, got Nr   zExpected number, got r   TFzExpected boolean, got zExpected JSON z, got )true1yes)false0no)r   r   )ru   r   rB   r   rs   rU   rV   rX   )r   rz   schema_types   && r'   rx   rx     s+    **VX.Ki	Is8O h	H: i99;..99;..1#9::))	T::c?"
 J/  	I5cW=>DH	I  	H4SG<=4G	H ## 	T~k]&HItS	Ts"   
B 
B< C B9<C)Dc          
          V ^8  d   QhR\         \        R3,          R\        R,          R\        \        \        3,          R\        \        \        3,          /# )r#   raw_args.
input_jsonNinput_schemar%   )tupler   r   r   )r&   s   "r'   r(   r(   )  sL     2 2CHo2d
2 sCx.2 
#s(^	2r)   c                   \        V 4      ^8X  d.   V ^ ,          P                  R4      '       d   Vf   V ^ ,          pRp / pVej    \        P                  ! V4      p\        X\        4      '       g,   \
        P                  R4       \        P                  ! ^4       VP                  V4       VP                  R/ 4      pV  Fm  pRV9  d0   \
        P                  RV R24       \        P                  ! ^4       VP                  R^4      w  rVP                  V/ 4      p
 \        W4      W8&   Ko  	  V#   \        P                   d:   p\
        P                  RT 24       \        P                  ! ^4        Rp?EL"Rp?ii ; i  \         d>   p\
        P                  R	T R
T 24       \        P                  ! ^4        Rp?EK  Rp?ii ; i)zBuild a tool-call argument dict from CLI inputs.

A single JSON object argument is treated as the full argument dict.
``--input-json`` provides the base dict; ``key=value`` pairs override.
Values are coerced using the tool's ``inputSchema``.
{Nz2[bold red]Error:[/bold red] Invalid --input-json: z>[bold red]Error:[/bold red] --input-json must be a JSON objectrk   =z3[bold red]Error:[/bold red] Invalid argument [cyan]u   [/cyan] — expected key=valuez+[bold red]Error:[/bold red] Argument [cyan]z	[/cyan]:  )lenr;   rU   rV   rX   r5   r6   r7   r8   r:   r   updateru   rM   rx   rB   )r   r   r   r{   parsedrF   rk   argkeyvalueprop_schemas   &&&        r'   parse_tool_argumentsr   )  s    8}hqk44S99j>Pa[
F	ZZ
+F &$''MMP HHQKf!!,3Jc>MMEcUJhi HHQKYYsA&
 nnS"-	&u:FK   M9 ## 	MMNseTUHHQKK	,  	MM=cU)C5Q HHQKK		s0   D4 !F4F	.E==FG1GGc                R    V ^8  d   QhR\         \        \        3,          R\        /# )r#   rz   r%   )r   r   r   )r&   s   "r'   r(   r(   c  s"     ? ?T#s(^ ? ?r)   c                (   RV 9   d3   V R,           Uu. uF  p\        V4      NK  	  ppRP                  V4      # V P                  RR4      p\        V\        4      '       d   RP                  R V 4       4      # \
        P                  W34      # u upi )zEProduce a short Python-style type string from a JSON-Schema fragment.anyOfz | rc   anyc              3   L   "   T F  p\         P                  W4      x  K  	  R # 5iN)_JSON_SCHEMA_TYPE_MAPru   ).0ts   & r'   	<genexpr>+_json_schema_type_to_str.<locals>.<genexpr>l  s     O;a/33A99;s   "$)_json_schema_type_to_strjoinru   r:   r   r   )rz   srN   r   s   &   r'   r   r   c  s     &6<WoFo)!,oFzz%  **VU+K+t$$zzO;OOO $$[>> Gs   Bc                X    V ^8  d   QhR\         P                  P                  R\        /# )r#   toolr%   )mcptypesToolr   )r&   s   "r'   r(   r(   q  s"      		 3 r)   c                   . pV P                   pVP                  R/ 4      p\        VP                  R. 4      4      pVP                  4        Fi  w  rV\	        V4      pWT9   d   VP                  V RV 24       K.  VP                  R4      pVe   \        V4      MRp	VP                  V RV RV	 24       Kk  	  V P                   RRP                  V4       R	2p
V P                  '       d"   \	        V P                  4      pV
R
V 2,          p
V
# )zKBuild ``name(param: type, ...) -> return_type`` from a tool's JSON schemas.rk   rl   rR   defaultz...z = (, ro   z -> )
inputSchemaru   rv   rw   r   appendreprnamer   outputSchema)r   ra   rz   rk   rl   	prop_namer   type_strr   default_reprsigrets   &           r'   format_tool_signaturer   q  s    FFL"-J6::j"-.H","2"2"4	+K8 MMYKr(45!ooi0G,3,?4=ULMMYKr(3|nEF #5 YYKq6*+1
-C&t'8'89cU|Jr)   c                V    V ^8  d   QhR\         R\        \         \        3,          RR/# )r#   labelrz   r%   Nr   )r&   s   "r'   r(   r(     s.     C C Cd38n C Cr)   c                    VP                  R/ 4      pV'       g   R# \        P                  RV  R\        P                  ! V4       R24       R# )z!Print a JSON schema with a label.rk   Nz	    [dim]rR   [/dim])ru   r5   r6   rU   dumps)r   rz   rk   s   && r'   _print_schemar     s=    L"-JMMIeWBtzz&'9&:&ABr)   c                (    V ^8  d   QhR\         RR/# )r#   r{   r%   N)r
   )r&   s   "r'   r(   r(     s     & &^ & &r)   c                x   V P                   '       d|   V P                   Fi  p\        V\        P                  P
                  4      '       d%   \        P                  RVP                   24       KQ  \        P                  RV 24       Kk  	  R# V P                  e6   \        P                  \        P                  ! V P                  4      4       R# V P                   EFX  p\        V\        P                  P
                  4      '       d"   \        P                  VP                  4       KO  \        V\        P                  P                  4      '       dL   \        VP                  4      ^,          ^,          p\        P                  RVP                    RV R24       K  \        V\        P                  P"                  4      '       dM   \        VP                  4      ^,          ^,          p\        P                  RVP                    RV R24       EK:  \        P                  \%        V4      4       EK[  	  R# )z/Pretty-print a tool call result to the console.r3   Nz[dim][Image: , ~ bytes][/dim]z[dim][Audio: )is_errorrj   r:   r   r   TextContentr5   r6   textstructured_content
print_jsonrU   r   ImageContentr   rY   mimeTypeAudioContentr   )r{   blocksizes   &  r'   _format_call_result_textr     sp    ^^E%!6!677 <UZZLIJ <UGDE	 $
 	  ,4::f&?&?@AeSYY2233MM%**%syy5566uzz?Q&!+DMMM%..)9TF-PQsyy5566uzz?Q&!+DMMM%..)9TF-PQMM#e*%  r)   c                z    V ^8  d   QhR\         P                  P                  R\        \        \
        3,          /# )r#   r   r%   )r   r   ContentBlockr   r   r   )r&   s   "r'   r(   r(     s,     4 4#))"8"8 4T#s(^ 4r)   c                   \        V \        P                  P                  4      '       d   RRRV P                  /# \        V \        P                  P
                  4      '       d   RRRV P                  RV P                  /# \        V \        P                  P                  4      '       d   RRRV P                  RV P                  /# RRR\        V 4      /# )	z5Serialize a single content block to a JSON-safe dict.rc   r   imager   rY   audiounknownr   )
r:   r   r   r   r   r   r   rY   r   r   )r   s   &r'   _content_block_to_dictr     s    %..//

33%//00U^^VUZZPP%//00U^^VUZZPPIwE
33r)   c                R    V ^8  d   QhR\         R\        \        \        3,          /# )r#   r{   r%   )r
   r   r   r   )r&   s   "r'   r(   r(     s"       DcN r)   c                    V P                    Uu. uF  p\        V4      NK  	  ppRVRV P                  /pV P                  e   V P                  VR&   V# u upi )z3Serialize a ``CallToolResult`` to a JSON-safe dict.rj   r   r   )rj   r   r   r   )r{   r   content_listouts   &   r'   _call_result_to_dictr     s^     @F~~N~e*51~LN$lJPC  ,$*$=$= !J	 Os   Ac                    V ^8  d   QhR\         \        P                  P                  ,          R\         \        \
        \        3,          ,          /# )r#   toolsr%   )r   r   r   r   r   r   r   )r&   s   "r'   r(   r(     s4      $syy~~. 4S#X3G r)   c           	         V  Uu. uFK  pRVP                   RVP                  RVP                  /VP                  '       d   RVP                  /M/ CNKM  	  up# u upi )z-Serialize a list of tools to JSON-safe dicts.r   descriptionr   r   )r   r   r   r   )r   r   s   & r'   _tools_to_jsonr     sg      A AFF1==1==	
 45>>>/r		
   s   ;AAc                    V ^8  d   QhR\         R\        R\        \        R3,          R\        R,          R\        RR/# )	r#   client	tool_name	arguments.r   Njson_outputr%   r   r   r   r   )r&   s   "r'   r(   r(     sP     . ... S#X. d
	.
 . 
.r)   c                  "   V P                  4       G Rj  xL
 pV Uu/ uF  qfP                  VbK  	  ppW9  d   \        P                  ! WP	                  4       ^RR7      pRV R2p	V'       d&   RP                  R V 4       4      p
V	RV
 R	2,          p	\        P                  R
V	 24       \        P                  ! ^4       Wq,          p\        W#VP                  4      p\        VP                  P                  R. 4      4      p\        VP	                  4       4      pW,
          pV'       d   RP                  R \        V4       4       4      p\        P                  RV 24       \        P                  4        \        V4      p\        P                  RV R24       \        P                  ! ^4       V P!                  WRR7      G Rj  xL
 pV'       d4   \        P#                  \$        P&                  ! \)        V4      4      4       M\+        V4       VP,                  '       d   \        P                  ! ^4       R# R#  EL.u upi  L~5i)z1Handle a tool call within an open client session.N      ?ncutoffzTool [cyan][/cyan] not found.r   c              3   .   "   T F  pR V R2x  K  	  R# 5iz[cyan]rQ   Nr   r   ms   & r'   r   $_handle_tool_call.<locals>.<genexpr>       #OAfQCw$7    Did you mean: ?r3   rl   c              3   .   "   T F  pR V R2x  K  	  R# 5ir   r   r   s   & r'   r   r     s     M_&7 3_r  z8[bold red]Error:[/bold red] Missing required arguments: z  [dim]r   F)raise_on_error)
list_toolsr   difflibget_close_matcheskeysr   r5   r6   r7   r8   r   r   rv   ru   sortedr   	call_toolr   rU   r   r   r   r   )r   r   r   r   r   r   r   tool_mapclose_matchesmsgsuggestionsr   parsed_argsrl   providedmissingmissing_strr   r{   s   &&&&&              r'   _handle_tool_callr    s     ##%%E#()5a	5H) 11}}!C
 I;&89))#O#OOK_[M33C4SE:;D&yd>N>NOK4##''
B78H;##%&H!GiiMVG_MMF{mT	
 	#D)uF+,##I5#QQF4::&:6&BCD ( K &): Rs9   IIIIFIIIAI*IIc                @    V ^8  d   QhR\         R\        R\        RR/# )r#   r   urir   r%   N)r   r   r   )r&   s   "r'   r(   r(     s6     #Q #Q#Q	#Q #Q 
	#Qr)   c           	       "   V P                  V4      G Rj  xL
 pV'       Ed   . pV F  p\        V\        P                  P                  4      '       dA   VP                  R\        VP                  4      RVP                  RVP                  /4       Km  \        V\        P                  P                  4      '       g   K  VP                  R\        VP                  4      RVP                  RVP                  /4       K  	  \        P                  \        P                  ! V4      4       R# V F  p\        V\        P                  P                  4      '       d"   \        P!                  VP                  4       KN  \        V\        P                  P                  4      '       g   Kz  \#        VP                  4      ^,          ^,          p\        P!                  RVP                   RV R24       K  	  R#  EL5i)	z5Handle a resource read within an open client session.Nr  r   r   blobz[dim][Blob: r   r   )read_resourcer:   r   r   TextResourceContentsr   r   r  r   r   BlobResourceContentsr  r5   r   rU   r   r6   r   )r   r  r   contentsrY   r   r   s   &&&    r'   _handle_resourcer    s^     ))#..H{E%!?!?@@s599~"ENN

 E399#A#ABBs599~"ENN

 " 	4::d+,eSYY;;<<MM%**%syy==>>uzz?Q&!+DMML(8D6OP 1 /s#   G=G:G=BG=C$G=+AG=c                    V ^8  d   QhR\         R\        R\        \        R3,          R\        R,          R\        RR/# )	r#   r   prompt_namer   .r   Nr   r%   r   )r&   s   "r'   r(   r(   3  sP     6 666 S#X6 d
	6
 6 
6r)   c           	        "   \        W#RR/4      pV P                  4       G Rj  xL
 pV Uu/ uF  qwP                  VbK  	  ppW9  d   \        P                  ! WP                  4       ^RR7      p	RV R2p
V	'       d&   RP                  R	 V	 4       4      pV
R
V R2,          p
\        P                  RV
 24       \        P                  ! ^4       T P                  Y;'       g    R4      G Rj  xL
 pV'       d   / pVP                  '       d   VP                  VR&   VP                   U
u. uF&  p
RV
P                  R\        V
P                   4      /NK(  	  up
VR&   \        P#                  \$        P&                  ! V4      4       R# VP                   EFP  p
\        P                  RV
P                   R24       \)        V
P                   \*        P,                  P.                  4      '       d.   \        P                  RV
P                   P0                   24       M\)        V
P                   \*        P,                  P2                  4      '       d_   \5        V
P                   P6                  4      ^,          ^,          p\        P                  RV
P                   P8                   RV R24       M"\        P                  RV
P                    24       \        P                  4        EKS  	  R#  ELu upi  ELu up
i 5i)z2Handle a prompt get within an open client session.rc   r   Nr   r   zPrompt [cyan]r   r   c              3   .   "   T F  pR V R2x  K  	  R# 5ir   r   r   s   & r'   r   !_handle_prompt.<locals>.<genexpr>I  r   r  r  r  r3   r   rolerj   messagesz[bold]z:[/bold]z  z  [dim][Image: r   r   )r   list_promptsr   r  r  r	  r   r5   r6   r7   r8   
get_promptr   r$  r#  r   rj   r   rU   r   r:   r   r   r   r   r   r   rY   r   )r   r  r   r   r   r  promptsp
prompt_mapr  r  r  r{   rY   r   s   &&&&&          r'   _handle_promptr*  3  sY     'yvx>PQK''))G%,-W&&!)WJ-$11*a
 k]*<=))#O#OOK_[M33C4SE:;$$[2E2EFFF!"("4"4D 

 ' 1#++> '
Z 	4::d+,sxxj12ckk399#8#899MMBs{{//012SYY%;%;<<s{{''(1,1DMM!#++"6"6!7s4&N MMBs{{m,- = *- G
sR   "K>K.K>K1B#K>&
K>0K61K>=K>K>.,K9FK>1K>9K>	resourcesFr'  r   output_schemar   c                   V ^8  d   QhR\         \        R,          \        P                  ! RR7      3,          R\         \        R,          \        P                  ! RRR7      3,          R\         \        R#,          R,          \        P                  ! R	R
.RR7      3,          R\         \
        \        P                  ! RRR7      3,          R\         \
        \        P                  ! RRR7      3,          R\         \
        \        P                  ! RRR7      3,          R\         \
        \        P                  ! RRR7      3,          R\         \
        \        P                  ! RRR7      3,          R\         \        R,          \        P                  ! RRR7      3,          R\         \        R,          \        P                  ! R R!R7      3,          R"R/# )$r#   r$   N4Server URL, Python file, MCPConfig JSON, or .js filehelpr    	--command7Stdio command to connect to (e.g. 'npx -y @mcp/server')r!   --transport-t2Force transport type for URL targets (http or sse)r   r0  r+  z--resourceszAlso list resourcesr'  z	--promptszAlso list promptsr   z--input-schemazShow full input schemasr,  z--output-schemazShow full output schemasr   --jsonOutput as JSONr   	--timeoutConnection timeout in secondsr   --authAAuth method: 'oauth', a bearer token string, or 'none' to disabler%   httpr+   r   r   cyclopts	Parameterr   r   r   )r&   s   "r'   r(   r(   q  s    R Rd
G	
	R d
J	
	R %&E	
	R, =/DE	G-R4 ;-@A	C5R< +2KL	N=RD ,3MN	PERL 8*:;	=MRT ;-LM	OUR\ d
T	
	]Rj 
kRr)   c       	        6  "   \        WVR7      p
\        WV	R7      p T;_uu_4       GRj  xL
  VP                  4       G Rj  xL
 pV'       Ed;   R\        V4      /pV'       dg   VP	                  4       G Rj  xL
 pV Uu. uF>  pR\        VP                  4      RVP                  RVP                  RVP                  /NK@  	  upVR	&   V'       d|   VP                  4       G Rj  xL
 pV UUu. uFQ  pRVP                  RVP                  R
VP                  ;'       g    .  Uu. uF  pVP                  4       NK  	  up/NKS  	  uppVR&   \        P                  \        P                   ! V4      4        RRR4      GRj  xL
  R# V'       g   \        P#                  R4       M\        P#                  R\%        V4       R24       \        P#                  4        V F  p\'        V4      p\        P#                  RV R24       VP                  '       d#   \        P#                  RVP                   24       V'       d   \)        RVP*                  4       V'       d)   VP,                  '       d   \)        RVP,                  4       \        P#                  4        K  	  V'       Ed   VP	                  4       G Rj  xL
 p\        P#                  R\%        V4       R24       \        P#                  4        V'       g   \        P#                  R4       V F  p\        P#                  RVP                   R24       VP                  ;'       g    RVP                  ;'       g    R.pRP/                  R V 4       4      pV'       g   Kt  \        P#                  RV 24       K  	  \        P#                  4        V'       Ed2   VP                  4       G Rj  xL
 p\        P#                  R\%        V4       R24       \        P#                  4        V'       g   \        P#                  R4       V F  pRpVP                  '       d;   VP                   Uu. uF  pVP                  NK  	  ppRRP/                  V4       R2p\        P#                  RVP                   V R24       VP                  '       g   K  \        P#                  RVP                   24       K  	  \        P#                  4        RRR4      GRj  xL
  R#  EL EL ELu upi  EL/u upi u uppi  EL ELi ELRu upi  L0  + GRj  xL 
 '       g   i     R# ; i  \0         d:   p\        P#                  RT 24       \2        P4                  ! ^4        Rp?R# Rp?ii ; i5i)a  List tools available on an MCP server.

Examples:
    fastmcp list http://localhost:8000/mcp
    fastmcp list server.py
    fastmcp list mcp.json --json
    fastmcp list --command 'npx -y @mcp/server' --resources
    fastmcp list http://server/mcp --transport sse
r    r!   r   r   Nr   r  r   r   r   r+  r   r'  z[dim]No tools found.[/dim]z[bold]Tools (z)[/bold]rn   rQ   z    InputOutputz[bold]Resources (z   [dim]No resources found.[/dim]rm   u    — c              3   8   "   T F  q'       g   K  Vx  K  	  R # 5ir   r   )r   r(  s   & r'   r   list_command.<locals>.<genexpr>  s     'C:a:s   	
z[bold]Prompts (z  [dim]No prompts found.[/dim]r   r   ro   r3   )rG   r   r  r   list_resourcesr   r  r   r   r   r%  r   
model_dumpr5   r   rU   r   r6   r   r   r   r   r   r   	Exceptionr7   r8   )r$   r    r!   r+  r'  r   r,  r   r   r   r[   r   r   rY   resrprmr(  ar   r   
desc_partsdescargs_strrN   rF   s   &$$$$$$$$$                r'   list_commandrS  q  s2    @ #;9UH84@FO66 ++--E{(/1F'G & 5 5 77C "%) "%A "3quu:"AFF)1==&

	 "%)D%  & 3 3 55C "%' "%A	 #AFF)1=='1;;CTCTRTCT)VCTQ!,,.CT)V
 "%'DO ""4::d#347 66< :;c%j\BC!D/5CMMHSE"9:'''T-=-=,>&?@#%gt/?/?@$):):):%h0A0ABMMO " y"1133 1#c(8DEMM"DEAMMHQUUG7";<"#&&,,B0C0C!DJ"<<'C:'CCDtTFm4  w"//11CzBCMM"BCA!H{{{12 =A =%&tyy'7&8#:MMHQVVHXJg"FG}}}Q]]O&<=  U 66-
 8) 6
 *W	'% ^ 4 2 !>K 666X  4SE:;s  VU T	U T5TT5(T5:T;T5ATT5T5(T)	T520T
#T
(TT
	1T5:U T%U 
VT5B0T5T5#T556T5,T5?T( BT5T5'!T58T5T5T+A>T5T.
-AT5=:T57U T3U V	U T5T5T5T
T5%U (T5+T5.T53U 5U	;T><
U	U		U VU V.VVVVpromptr   c                l   V ^8  d   QhR\         \        R,          \        P                  ! RR7      3,          R\         \        \        P                  ! RR7      3,          R\        R\         \        R,          \        P                  ! R	R
R7      3,          R\         \        R ,          R,          \        P                  ! RR.RR7      3,          R\         \
        \        P                  ! RRR7      3,          R\         \        R,          \        P                  ! RRR7      3,          R\         \
        \        P                  ! RRR7      3,          R\         \        R,          \        P                  ! RRR7      3,          R\         \        R,          \        P                  ! RRR7      3,          RR/# )!r#   r$   Nr.  r/  targetz7Tool name, resource URI, or prompt name (with --prompt)r   r    r1  r2  r!   r3  r4  r5  r6  rT  z--promptzTreat target as a prompt namer   z--input-jsonz5JSON string of arguments (merged with key=value args)r   r7  zOutput raw JSON resultr   r9  r:  r   r;  r<  r%   r=  r?  )r&   s   "r'   r(   r(     s    b bd
G	
	b J	
	b b d
J	
	b* %&E	
	+b8 :,KL	N9b@ d
H	
	AbN 8*BC	EObV ;-LM	OWb^ d
T	
	_bl 
mbr)   c          	     j  "   V'       g,   \         P                  R4       \        P                  ! ^4       \	        WVR7      p
\        WVR7      p T;_uu_4       GRj  xL
  V'       d   \        WWV4      G Rj  xL
  M1RV9   d   \        WV4      G Rj  xL
  M\        WWV4      G Rj  xL
  RRR4      GRj  xL
  R#  Le LJ L0 L L  + GRj  xL 
 '       g   i     R# ; i  \         d:   p\         P                  RT 24       \        P                  ! ^4        Rp?R# Rp?ii ; i5i)a?  Call a tool, read a resource, or get a prompt on an MCP server.

By default the target is treated as a tool name. If the target
contains ``://`` it is treated as a resource URI. Pass ``--prompt``
to treat it as a prompt name.

Arguments are passed as key=value pairs. Use --input-json for complex
or nested arguments.

Examples:
    ```
    fastmcp call server.py greet name=World
    fastmcp call server.py resource://docs/readme
    fastmcp call server.py analyze --prompt data='[1,2,3]'
    fastmcp call http://server/mcp create --input-json '{"tags": ["a","b"]}'
    ```
z[bold red]Error:[/bold red] Missing target.

Usage: fastmcp call <server> <target> [key=value ...]

  target can be a tool name, a resource URI, or a prompt name (with --prompt).

Use [cyan]fastmcp list <server>[/cyan] to see available tools.rC  rD  Nz://r3   )
r5   r6   r7   r8   rG   r   r*  r  r  rK  )r$   rV  r    r!   rT  r   r   r   r   r   r[   r   rF   s   &&$$$$$$$*   r'   call_commandrX    s     R M	
 	";9UH84@F66$VYKXXX&&v{CCC'I;   66XC 666  4SE:;s   AD3C, C C, #C<C=CC	C.C/C3C, >C?C, D3C, C	CCC, C)	C
C)	!C)	#C, 'D3)C, ,D07.D+%D3+D00D3sourcec          
          V ^8  d   QhR\         \        \        ,          R,          \        P                  ! RRR7      3,          R\         \
        \        P                  ! RRR7      3,          R	R/# )
r#   rY  Nz--sourcezGOnly show servers from these sources (e.g. claude-code, cursor, gemini)r/  r   r7  r8  r%   )r   r   r   r@  rA  r   )r&   s   "r'   r(   r(   k  su     Y YS	DZ	
	Y 8*:;	=Y 
Yr)   c                  "   \        4       pV '       d$   V Uu. uF  q3P                  V 9   g   K  VNK  	  ppV'       d   V Uu. uFJ  pRVP                  RVP                  RVP                  RVP                  R\        VP                  4      /NKL  	  pp\        P                  \        P                  ! V4      4       R# V'       g   \        P                  R4       \        P                  4        \        P                  R4       \        P                  R	4       \        P                  R
4       \        P                  R4       \        P                  R4       \        P                  R4       \        P                  R4       R# ^ RIHp / pV F.  pVP                  VP                  . 4      P                  V4       K0  	  VP!                  4        F  w  rx\        P                  4        \        P                  RV 24       \        P                  RV^ ,          P                   R24       \        P                  4        V! RRRRRRR7      p	V	P#                  RRR7       V	P#                  RRR7       V F)  pV	P%                  VP                  VP                  4       K+  	  \        P                  V	4       \        P                  4        K  	  R# u upi u upi 5i)a  Discover MCP servers configured in editor and project configs.

Scans Claude Desktop, Claude Code, Cursor, Gemini CLI, Goose, and
project-level mcp.json files for MCP server definitions.

Discovered server names can be used directly with ``fastmcp list``
and ``fastmcp call`` instead of specifying a URL or file path.

Examples:
    fastmcp discover
    fastmcp discover --source claude-code
    fastmcp discover --source cursor --source gemini --json
    fastmcp list weather
    fastmcp call cursor:weather get_forecast city=London
r   rY  qualified_nametransport_summaryconfig_pathNz [dim]No MCP servers found.[/dim]z	Searched:u     • Claude Desktop configu"     • ~/.claude.json (Claude Code)u+     • .cursor/mcp.json (walked up from cwd)u*     • ~/.gemini/settings.json (Gemini CLI)u)     • ~/.config/goose/config.yaml (Goose)u     • ./mcp.json)Tablez[bold]Source:[/bold]  z[bold]Config:[/bold]  [dim]r   TboldF)show_headerheader_style	show_edgepad_edgeboxpaddingServercyan)style	Transportdim)    r#   )r   rY  r   r\  r]  r   r^  r5   r   rU   r   r6   
rich.tabler_  
setdefaultr   rw   
add_columnadd_row)
rY  r   serversr   rY   r_  	by_sourcesource_namegrouptables
   $$        r'   discover_commandrv  k  s<    <  G%<gV);11g< 	&
  !(( !"2"2#Q%8%8s1==1  	 	&
 	4::d+,89k"34:;CDBCAB()  46IQXXr*11!4  (oo/.{m<=3E!H4H4H3IPQ
 	0E2AMM!&&!"5"56  	e+ 0G =	&
s.   KKK	K KAK4K	HKc                b    V ^8  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   # )r#   r   )__conditional_annotations__r   r   )r&   s   "r'   r(   r(      s'     E E< tCH~ = Fr)   r   )Nrm   )=rx  __doc__r  rU   rL   r7   pathlibr   typingr   r   r   r@  rp   r   rich.consoler   fastmcp.cli.discoveryr   r   r	   fastmcp.client.clientr
   r   fastmcp.client.elicitationr   fastmcp.client.transports.baser   fastmcp.client.transports.httpr   fastmcp.client.transports.sser   fastmcp.client.transports.stdior   fastmcp.utilities.loggingr   loggerr5   r   rG   r9   r@   r]   r   r   rx   r   r   r   r   r   r   r   r   r  r  r*  rS  rX  rv  r(   )rx  s   @r'   <module>r     s   E    
  * *     R R 8 3 : B 6 : 0	L	!
) eugvVf
F)  E E !	EP<8I89v ! 	HD2t?>C&84&.b#QL6|R 	R* 	+R2 	3R: 	;RB 	CRJ 	KRR 	SRZ 	[Rh 	iR Rjb( 	)b6 	7b> 	?bL 	MbT 	Ub\ 	]bj 	kb bJY 	Y 	Y Yr)   