
    k7i                     
   S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJr  \" \5      rS
\S\\\4   4S jrS\S\S-  S\\   S-  S\\   S-  S\S-  S\\\S-  \\\   \\\4   S-  4   4S jrg)z&Shared utilities for install commands.    N)Path)dotenv_values)ValidationError)print)
get_logger)MCPServerConfig)FileSystemSourceenv_varreturnc                     SU ;  a%  [        SU  S35        [        R                  " S5        U R                  SS5      u  pUR	                  5       UR	                  5       4$ )z6Parse environment variable string in format KEY=VALUE.=z1[red]Invalid environment variable format: '[bold]z![/bold]'. Must be KEY=VALUE[/red]   )r   sysexitsplitstrip)r
   keyvalues      T/home/james-whalen/.local/lib/python3.13/site-packages/fastmcp/cli/install/shared.pyparse_env_varr      sU    
'?yHij	
 	sA&JC99;%%    server_specserver_namewith_packagesenv_varsenv_filec                 z  #    U=(       d    / nU=(       d    / nSnU R                  S5      (       Ga  [        U 5      R                  5       nUR                  5       (       d%  [	        SU S35        [
        R                  " S5         [        U5       n[        R                  " U5      nSSS5        SW;   a"  [	        S5        [
        R                  " S5        Oy[        R                  " U5      nUR                  R                  (       a5  [        UR                  R                  5      n	[        [        X)-   5      5      nO[%        U S	9n[        US
9n[        UR&                  R(                  5      R                  5       n[+        UR&                  S5      (       a  UR&                  R,                  OSn[.        R1                  S[3        U5      UUUS.S9  UnSnU(       d/   UR&                  R5                  5       I Sh  vN nUR6                  nU(       a  [?        US/ 5      O/ nU(       a0  SSK nURC                  S[D        SS9  [        [        UU-   5      5      nSnU(       d  U(       a^  0 nU(       a9   U[G        U5      RI                  5        VVs0 s H  u  nnUc  M  UU_M     snn-  nU H  n[M        U5      u  nnUUU'   M     XXU4$ ! , (       d  f       GN,= f! [        R                   ["        4 a0  n
[	        SU
 S35        [
        R                  " S5         Sn
A
GNSn
A
ff = f GN0! [8        [:        4 a6  n
[.        R1                  SS[3        U
5      0S9  UR<                  n Sn
A
GNcSn
A
ff = fs  snnf ! [J         a0  n
[	        SU
 S35        [
        R                  " S5         Sn
A
GNSn
A
ff = f7f)zProcess common arguments shared by all install commands.

Handles both fastmcp.json config files and traditional file.py:object syntax.
Nz.jsonz#[red]Configuration file not found: z[/red]r   
mcpServersz=[red]MCPConfig files are not supported for installation[/red]z![red]Invalid configuration file: )path)source
entrypointzInstalling server)filer   server_objectr   )extrazFCould not import server (likely missing dependencies), using file nameerrordependenciesr   zServer uses deprecated 'dependencies' parameter (deprecated in FastMCP 2.11.4). Please migrate to fastmcp.json configuration file. See https://gofastmcp.com/docs/deployment/server-configuration for details.   )
stacklevelz[red]Failed to load .env file: )'endswithr   resolveexistsr   r   r   openjsonloadr   	from_fileenvironmentr&   listsetJSONDecodeErrorr   r	   r    r   hasattrr!   loggerdebugstrload_servernameImportErrorModuleNotFoundErrorstemgetattrwarningswarnDeprecationWarningr   items	Exceptionr   )r   r   r   r   r   configconfig_pathfdataconfig_packageser    r"   r#   r9   serverserver_dependenciesr>   env_dictkvr
   r   r   s                           r   process_common_argsrN      sI     "'RM~2HFG$$;'//1!!##7}FKLHHQK	k"ayy| # t#UV )22;? %%22&*6+=+=+J+J&KO$(]-L)M$NM "{3 / ""#++-D$+FMM<$H$H  d  LLI&**	
   DF	!==4466F;;D BH'&."=RZ  	 	
 S1D!DEF '+H8%28%<%B%B%D%DTQDAqD%D   G&w/JC!HSM   X==u #"" $$o6 	5aS?@HHQKK	< 701 	LLXA'   99D	:  7s&ABs   BN;K K(/K N;A&K >B N;L/ <L,=L/ A&N;4M> 
M8M8&M> ,!N;
KK L)9%L$N;$L))N;,L/ /M5?+M0*N;0M55N;8M> >
N8%N3-N;3N88N;)__doc__r-   r   pathlibr   dotenvr   pydanticr   richr   fastmcp.utilities.loggingr   #fastmcp.utilities.mcp_server_configr   9fastmcp.utilities.mcp_server_config.v1.sources.filesystemr	   __name__r5   r7   tupler   r1   dictrN    r   r   <module>r[      s    ,  
    $  0 ? V	H	&3 &5c? &q>q>tq> 9t#q> 3i$	q>
 Tkq> 4tS$s)T#s(^d-BBCq>r   