+
    Q(ic<                     2  a  RG t-0 t R t^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
Ht ^ RIHt ^ RIHtHt ^ RIHt ^ RIHtHt ^ RIHtHt ^ RIHt ^ R	IHt ^ R
IHt ]! R4      t]RH,          t ]RI,          t!0 RkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkR kR!kR"kR#kR$kR%kR&kR'kR(kR)kR*kR+kR,kR-kR.kR/kR0kt"] ^ k R1 R2 lt#R3 R4 lt$R5 R6 lt%R7 R8 lt&RJR9 R: llt'R;RR<R/R= R> llt(RKR? R@ llt)RA RB lt*RC RD lt+RLRE RF llt,R# )Mz<FastMCP run command implementation with enhanced type hints.N)Callable)Path)AnyLiteral)FastMCP)Changeawatch)r   create_proxy)
get_logger)MCPServerConfig)FileSystemSourcezcli.runz.pyz.jsz.tsz.jsxz.tsxz.htmlz.mdz.mdxz.txtz.xmlz.cssz.scssz.sassz.less.jsonz.yamlz.ymlz.tomlz.vuez.sveltez.graphqlz.gqlz.svgz.pngz.jpgz.jpegz.gifz.icoz.webpz.mp3z.mp4z.wavz.webmz.woffz.woff2z.ttfz.eotc                0    V ^8  d   QhR\         R\        /# )   pathreturn)strbool)formats   "U/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/cli/run.py__annotate__r   S   s     ) ) ) )    c                b    \         P                  ! R4      p\        VP                  V 4      4      # )zCheck if a string is a URL.z
^https?://)recompiler   match)r   url_patterns   & r   is_urlr   S   s&    **]+K!!$'((r   c                0    V ^8  d   QhR\         R\        /# )r   urlr   )r   r   )r   s   "r   r   r   Y   s      c c r   c                     ^ RI pVP                  V 4      p\        V4      pV#   \         d=   p\        P                  RT  RT 24       \        P                  ! ^4        Rp?R# Rp?ii ; i)zyCreate a FastMCP server from a client URL.

Args:
    url: The URL to connect to

Returns:
    A FastMCP server instance
Nz Failed to create client for URL z: )fastmcpClientr	   	Exceptionloggererrorsysexit)r   r!   clientserveres   &    r   create_client_serverr+   Y   s^    $f% 7uBqcBCs   !$ A+1A&&A+c                >    V ^8  d   QhR\         R\        R,          /# )r   mcp_config_pathr   N)r   r   )r   s   "r   r   r   m   s      d wt} r   c                    V P                  4       ;_uu_ 4       p\        P                  ! V4      pRRR4       \        X4      pV#   + '       g   i     L; i)z)Create a FastMCP server from a MCPConfig.N)openjsonloadr	   )r-   src
mcp_configr)   s   &   r   create_mcp_config_serverr4   m   s?    					3YYs^
 
  *%FM	 
 	s   AA	c                0    V ^8  d   QhR\         R\        /# )r   config_pathr   )r   r   )r   s   "r   r   r   v   s        r   c                h    \         P                  ! V 4      pVP                  P                  V 4       V# )zLoad a FastMCP configuration from a fastmcp.json file.

Args:
    config_path: Path to fastmcp.json file

Returns:
    MCPServerConfig object
)r   	from_file
deploymentapply_runtime_settings)r6   configs   & r   load_mcp_server_configr<   v   s/     &&{3F ,,[9Mr   c                
   V ^8  d   QhR\         R\        R,          R\         R,          R\        R,          R\         R,          R\        R,          R\        \         ,          R,          R	\
        R
\
        R\
        R\
        RR/# )r   server_spec	transportNhostportr   	log_levelserver_argsshow_banneruse_direct_importskip_source	statelessr   )r   TransportTypeintLogLevelTypelistr   )r   s   "r   r   r      s     z zzt#z *z *	z
 *z d"z cT!z z z z z 
zr   c                  "   \        V 4      '       d&   \        V 4      p\        P                  RV  24       EMV P	                  R4      '       Ed   \        V 4      p\        V4      ;_uu_ 4       p\        P                  ! V4      pRRR4       RX9   d   \        V4      pEM(\        V4      pT;'       g    VP                  P                  pT;'       g    VP                  P                  pT;'       g    VP                  P                  pT;'       g    VP                  P                  pT;'       g    VP                  P                   pVe   TMVP                  P"                  pV	'       g   VP%                  4       G Rj  xL
 MR ^ RIHp ^ RIHp V'       d	   V! V4      MV! 4       pT;_uu_ 4        VP.                  P1                  4       G Rj  xL
 pRRR4       \        P                  RXP2                   RV 24       M\5        V R	7      p\7        VR
7      pV	'       g   VP%                  4       G Rj  xL
 MR ^ RIHp ^ RIHp V'       d	   V! V4      MV! 4       pT;_uu_ 4        VP.                  P1                  4       G Rj  xL
 pRRR4       \        P                  RXP2                   RVP                   24       \9        V\:        4      '       d   \=        WW1R7      G Rj  xL
  R# / pV'       d   VVR&   V'       d   VVR&   V'       d   VVR&   V'       d   VVR&   V'       d   VVR&   V
'       d   RVR&   V'       g   RVR&    VP>                  ! R/ VB G Rj  xL
  R#   + '       g   i     EL; i EL EL  + '       g   i     EL; i ELc EL  + '       g   i     EL; i L LP  \@         d:   p\        PC                  RT 24       \D        PF                  ! ^4        Rp?R# Rp?ii ; i5i)a  Run a MCP server or connect to a remote one.

Args:
    server_spec: Python file, object specification (file:obj), config file, or URL
    transport: Transport protocol to use
    host: Host to bind to when using http transport
    port: Port to bind to when using http transport
    path: Path to bind to when using http transport
    log_level: Log level
    server_args: Additional arguments to pass to the server
    show_banner: Whether to show the server banner
    use_direct_import: Whether to use direct import instead of subprocess
    skip_source: Whether to skip source preparation step
    stateless: Whether to run in stateless mode (no session)
z Created client proxy server for r   N
mcpServers)nullcontext)	with_argvzFound server "z" from config )r   )sourcez" in )r@   rA   r?   r?   r@   rA   r   rB   TrG   FrD   zFailed to run server:  )$r   r+   r$   debugendswithr   r/   r0   r1   r4   r<   r9   r?   r@   rA   r   rB   argsprepare_source
contextlibrN   fastmcp.cli.clirO   rP   load_servernamer   r   
isinstance	FastMCP1xrun_v1_server_async	run_asyncr#   r%   r&   r'   )r>   r?   r@   rA   r   rB   rC   rD   rE   rF   rG   r)   r6   fdatar;   rN   rO   argv_contextrP   kwargsr*   s   &&&&&&&&&&&           r   run_commandrb      s,    : k%k27}EF			g	&	&;'+!99Q<D  4-k:F ,K8F "@@V%6%6%@%@I116,,11D116,,11D116,,11D!@@V%6%6%@%@I*6F<M<M<R<R 
 2=&'')))$ /1 6A9[1kmL%}}88::  LL>&++n[MRS "{3 / .9f##%%%d 	+- 2=y-+-\!==4466F  	~fkk]%}EF
 &)$$!&$TTTF'{vvv'{"{ %}((((e , * ;  	& 7 \\ 	U* 	) -aS12s4  APP/M1/P6PP6PP6:P1PNPP8NNNA!P<N=PP0N%N"N%AP0N91PPPP(P5PPPN= *N;+N= /P1N	<
PNN	
P"N%%N6	0
P;N= =P.O<6P<PPenv_command_builder
extra_argsc                    V ^8  d   QhR\         R\        \        \         ,          .\        \         ,          3,          R,          R\        \         ,          R,          RR/# )r   module_namerc   Nrd   r   )r   r   rK   )r   s   "r   r   r     sT     $ $$ "49+tCy"89D@$ S	D 	$
 
$r   c                  Ve   RM\         P                  pVRV .pV'       d   VP                  V4       Ve	   V! V4      p\        P	                  RRP                  V4       24        \        P                  ! VRR7      p\         P                  ! VP                  4       R#   \        P                   dQ   p\        P                  RT  R	TP                   24       \         P                  ! TP                  4        Rp?R# Rp?ii ; i)
a  Run a Python module directly using ``python -m <module>``.

When ``-m`` is used, the module manages its own server startup.
No server-object discovery or transport overrides are applied.

Args:
    module_name: Dotted module name (e.g. ``my_package``).
    env_command_builder: An optional callable that wraps a command list
        with environment setup (e.g. ``UVEnvironment.build_command``).
    extra_args: Extra arguments forwarded after the module name.
Npythonz-mzRunning module:  T)checkzModule z exited with code )r&   
executableextendr$   rR   join
subprocessrunr'   
returncodeCalledProcessErrorr%   )rf   rc   rd   rh   cmdprocessr*   s   &$$    r   run_module_commandrt     s    ( -8XcnnFdK0C

: &!#&
LL#CHHSM?34..D1##$(( w{m+=all^LMs   )8B# #D8ADDc          
      v    V ^8  d   QhR\         R\        R,          R\        R,          R\        R,          RR/# )r   r)   r@   NrA   r?   r   )r[   r   rI   rH   )r   s   "r   r   r   +  sG     ) ))
*) *) t#	)
 
)r   c                h  "   V'       d   WP                   n        V'       d   W P                   n        T;R8X  d    V P                  4       G Rj  xL
  R# ;;R8X  d   M;R8X  d   M;f   M M  V P	                  4       G Rj  xL
  R# R8X  d   V P                  4       G Rj  xL
  R# R#  L\ L* L5i)zRun a FastMCP 1.x server using async methods.

Args:
    server: FastMCP 1.x server instance
    host: Host to bind to
    port: Port to bind to
    transport: Transport protocol to use
stdioNhttpstreamable-httpsse)settingsr@   rA   run_stdio_asyncrun_streamable_http_asyncrun_sse_async)r)   r@   rA   r?   s   &&&&r   r\   r\   +  s}      ##
((***.V'$.22444&&(((  +4(s:    B2,B2B,3B2B.B2#B0$	B2.B20B2c                <    V ^8  d   QhR\         R\        R\        /# )r   _changer   r   )r   r   r   )r   s   "r   r   r   G  s&     A A6 A A Ar   c                   a \         ;QJ d#    V3R l\         4       F  '       g   K   R# 	  R# ! V3R l\         4       4      # )z,Filter for files that should trigger reload.c              3   F   <"   T F  pSP                  V4      x  K  	  R # 5i)N)rS   ).0extr   s   & r   	<genexpr> _watch_filter.<locals>.<genexpr>I  s     @-?ct}}S!!-?s   !TF)anyWATCHED_EXTENSIONS)r   r   s   &fr   _watch_filterr   G  s.    3@-?@33@3@3@-?@@@r   c                P    V ^8  d   QhR\         P                  P                  RR/# )r   rs   r   N)asynciorn   Process)r   s   "r   r   r   L  s&      g&8&8&@&@ T r   c                T  "   V P                   e   R# V P                  p\        P                  R8w  d   \        P
                  ! \        \        4      ;_uu_ 4        \        P                  ! \        P                  ! V4      \        P                  4       RRR4        \        P                  ! V P                  4       RR7      G Rj  xL
  R# V P%                  4        V P                  4       G Rj  xL
  R#   + '       g   i     Lk; i LC  \        P                    d     Mi ; i\        P
                  ! \        \        4      ;_uu_ 4        \        P                  ! \        P                  ! T4      \        P"                  4       RRR4       K    + '       g   i     L; i L5i)zTerminate a subprocess and all its children.

Sends SIGTERM to the process group first for graceful shutdown,
then falls back to SIGKILL if the process doesn't exit in time.
Nwin32g      @)timeout)rp   pidr&   platformrV   suppressProcessLookupErrorOSErroroskillpggetpgidsignalSIGTERMr   wait_forwaitTimeoutErrorSIGKILLkill)rs   r   s   & r   _terminate_processr   L  s     %
++C
||w  !3W==IIbjjov~~6 >	""7<<>3??? 	
,,.! >=
 @## 		   !3W==IIbjjov~~6 >===
 sx   AF(:C8F()D DD %F(1F&2F(8D	F(D D%"F($D%%*F(:F	
F(F#		F(c                z    V ^8  d   QhR\         \        ,          R\         \        ,          R,          R\        RR/# )r   rr   reload_dirsNis_stdior   )rK   r   r   r   )r   s   "r   r   r   l  sC     y. y.	cy.dd"y. y. 
	y.r   c                
  a"   T;'       g    \         P                  ! 4       .pRpRpV'       d   \        P                  R4       M\        P                  R4       \        P
                  ! 4       o\        P                  ! 4       pR V3R llp\        P                  R8w  dA   VP                  \        P                  V4       VP                  \        P                  V4        SP                  4       '       Eg   V'       g   RV 9   d   T pM. V ORNpR	p\        P                  ! VR
RRRRRR\        P                  R8g  / G Rj  xL
 p\        P                  ! \!        \#        \%        VR\&        / 4      4      4      p	\        P                  ! VP)                  4       4      p
\        P                  ! SP)                  4       4      p\        P(                  ! WV.\        P*                  R7      G Rj  xL
 w  rV FR  pVP-                  4        \.        P0                  ! \        P2                  4      ;_uu_ 4        VG Rj  xL
  RRR4       KT  	  W9   d   EMW9   EdH   V
P5                  4       pV^ 8w  d   \        P7                  RV R24       M\        P                  R4       \        P                  ! \!        \#        \%        VR\&        / 4      4      4      p	\        P                  ! SP)                  4       4      p\        P(                  ! W.\        P*                  R7      G Rj  xL
 w  rV FR  pVP-                  4        \.        P0                  ! \        P2                  4      ;_uu_ 4        VG Rj  xL
  RRR4       KT  	  W9   d   Ma\        P                  R4       EK  V	P5                  4       p\        P                  R\9        V4       R24       \;        V4      G Rj  xL
  EK   \        P                  R8w  d?   VP?                  \        P                  4       VP?                  \        P                  4       V'       d&   VP@                  f   \;        V4      G Rj  xL
  R# R# R#  EL- EL EL8  + '       g   i     EK  ; i ELg EL  + '       g   i     EKv  ; i L  \<         d    \        P                  R4        Li ; i Lk  \        P                  R8w  d?   TP?                  \        P                  4       TP?                  \        P                  4       T'       d%   TP@                  f   \;        T4      G Rj  xL 
  i i i ; i5i)zRun a command with file watching and auto-reload.

Args:
    cmd: Command to run as subprocess (should include --no-reload)
    reload_dirs: Directories to watch for changes (default: cwd)
    is_stdio: Whether this is stdio transport
NTz.Reload mode enabled (using stateless sessions)zReload mode enabled (using stateless HTTP). Some features requiring bidirectional communication (like elicitation) are not available.c                    V ^8  d   QhRR/# )r   r   NrQ   )r   s   "r   r   %run_with_reload.<locals>.__annotate__  s      D r   c                  R   < \         P                  R 4       S P                  4        R# )%Received shutdown signal, stopping...N)r$   infoset)shutdown_events   r   signal_handler'run_with_reload.<locals>.signal_handler  s    ;<r   r   z--no-bannerFstdinstdoutstderrstart_new_sessionwatch_filter)return_whenzServer exited with code z, waiting for file change...z)Server exited, waiting for file change...zDetected changes, restarting...zDetected changes in z file(s), restarting...r   )!r   cwdr$   r   r   Eventget_running_loopr&   r   add_signal_handlerr   r   SIGINTis_setcreate_subprocess_execcreate_taskanextaiterr   r   r   FIRST_COMPLETEDcancelrV   r   CancelledErrorresultr%   lenr   KeyboardInterruptremove_signal_handlerrp   )rr   r   r   watch_pathsrs   	first_runloopr   run_cmd
watch_task	wait_taskshutdown_taskdonependingtaskcodechangesr   s   &&&              @r   run_with_reloadr   l  s1     --$((*K15GIDE4	
 ]]_N##%D 
 ||w?~>S. ''))MS0/C//I#::  	 #&,,'"9 G !,,eFKLmLMNJ  ++GLLN;I#//0C0C0EFM"),,6#33# MD
  (()?)?@@JJ A@  
 $  '')19LL24&8TU KK KL %00% P- PQR
 !( 3 3N4G4G4I J&-ll/ ' 7 7' ! $DKKM#,,W-C-CDD"

 ED $ !(=> %++-*3w<.8OP )111M *\ <<7"&&v~~6&&v}}5w))1$W--- 27S   A@@,! # EDD 2 =;<= .	 <<7"&&v~~6&&v}}5w))1$W--- 27s'  ,UB3U$R- ;R- AR- Q2B,R- 2Q53AR- :Q; Q8
Q;R- S CR- )R*AR- 1R7R
8R<R- S AR- 'R+(R- /S 0AUU'S(
U2R- 5R- 8Q;;RR- RR(!R- - SS SS UAU1UUUUc                V    V ^8  d   Qh/ ^ \         9   d   \        \        ,          ;R&   # )r   r   )__conditional_annotations__r   r   )r   s   "r   r   r      s#     B B>0 0CH 0? Cr   )rw   rx   rz   ry   )DEBUGINFOWARNINGERRORCRITICAL)
NNNNNNTFFF)NNN)NF).r   __doc__r   rV   r0   r   r   r   rn   r&   collections.abcr   pathlibr   typingr   r   mcp.server.fastmcpr   r[   
watchfilesr   r   fastmcp.server.serverr	   fastmcp.utilities.loggingr
   #fastmcp.utilities.mcp_server_configr   9fastmcp.utilities.mcp_server_config.v1.sources.filesystemr   r$   rH   rJ   r   r   r+   r4   r<   rb   rt   r\   r   r   r   r   )r   s   @r   <module>r      sQ   B    	 	   
 $   3 % 7 0 W	I	 ABFG0 	0  
	0 
 
0  0  0  0  
0  0  0  0  0   !0 " #0 $ %0 ( )0 * +0 , -0 . /0 2 30 4 50 8 90 : ;0 > ?0 @ A0 B C0 D E0 F G0 H I0 J K0 N O0 P Q0 R S0 T U0 X Y0 Z [0 \ ]0 ^ _0   0f)("zz$ DH$ $(	$N)8A
@y. y.r   