
    k7i                        S r SSKrSSKrSSKJr  SSKJr  SSKrSSKJ	r	  SSK
JrJr  SSKJr  SSKJr  S	S
KJr  \" \5      rS\S-  4S jrSSSSSSS.S\S\S-  S\S\\   S-  S\\   S-  S\\\4   S-  S\S-  S\S-  S\S-  S\4S jjrSSSSSSSSS.S\S\\S-  \R6                  " SS/SS94   S\\\   S-  \R6                  " SS S!S"94   S\\\   S-  \R6                  " S#S$S!S"94   S\\\   S-  \R6                  " S%S&S!S"94   S'\\S-  \R6                  " S(S)S*94   S+\\S-  \R6                  " S,S-S*94   S\\S-  \R6                  " S.S/S*94   S\\S-  \R6                  " S0S1S*94   SS4S2 jjrg)3z>Claude Desktop integration for FastMCP install using Cyclopts.    N)Path)	Annotated)print)StdioMCPServerupdate_config_file)
get_logger)UVEnvironment   )process_common_argsreturnc                     [         R                  S:X  a"  [        [        R                  " 5       SSS5      n O[         R                  S:X  a"  [        [        R                  " 5       SSS5      n Of[         R                  R	                  S5      (       aA  [        [
        R                  R                  S	[        R                  " 5       S
-  5      S5      n OgU R                  5       (       a  U $ g)z2Get the Claude config directory based on platform.win32AppDataRoamingClaudedarwinLibraryzApplication SupportlinuxXDG_CONFIG_HOMEz.configN)	sysplatformr   home
startswithosenvirongetexists)paths    \/home/james-whalen/.local/lib/python3.13/site-packages/fastmcp/cli/install/claude_desktop.pyget_claude_config_pathr       s    
||wDIIKIx@		!DIIK,A8L		 	 	)	)JJNN,diikI.EF
 {{}}    )with_editablewith_packagesenv_varspython_versionwith_requirementsprojectfileserver_objectnamer"   r#   r$   r%   r&   r'   c                   [        5       n	U	(       d  [        S5        gU	S-  n
[        UU=(       d    / S/-   UUUS9nU(       a  U R                  5        SU 3nO[	        U R                  5       5      nUR                  SSU/5      n[        US   US	S
 U=(       d    0 S9n U
R                  5       (       ax  SS
KnU
R                  5       R                  5       nU(       aO  UR                  U5      nSU;   a8  UUS   ;   a/  US   U   R                  S0 5      nU(       a  0 UEUEnOUnUUl        [        XU5        [        SU S35        g! [         a  n[        SU S35         S
nAgS
nAff = f)a  Install FastMCP server in Claude Desktop.

Args:
    file: Path to the server file
    server_object: Optional server object name (for :object suffix)
    name: Name for the server in Claude's config
    with_editable: Optional list of directories to install in editable mode
    with_packages: Optional list of additional packages to install
    env_vars: Optional dictionary of environment variables
    python_version: Optional Python version to use
    with_requirements: Optional requirements file to install from
    project: Optional project directory to run within

Returns:
    True if installation was successful, False otherwise
z[red]Claude Desktop config directory not found.[/red]
[blue]Please ensure Claude Desktop is installed and has been run at least once to initialize its config.[/blue]Fzclaude_desktop_config.jsonfastmcp)pythondependenciesrequirementsr'   editable:runr   r
   N)commandargsenv
mcpServersr5   z[green]Successfully installed 'z' in Claude Desktop[/green]Tz[red]Failed to install server: z[/red])r    r   r	   resolvestrbuild_commandr   r   json	read_textstriploadsr   r5   r   	Exception)r(   r)   r*   r"   r#   r$   r%   r&   r'   
config_dirconfig_file
env_configserver_specfull_commandserver_configr:   contentconfigexisting_env
merged_enves                        r   install_claude_desktoprJ   &   s   8 ()J~	
 ;;K#)ri[8&J (-9$,,.) ++Y{,KLL #Q!"NM!++-335GG,6)df\6J.J#),#7#=#A#A%#LL%A%A%A
%1
(2M% 	;m</v5PQR /s&9:s   "B(E 
E.E))E.)server_namer"   r#   r$   env_filer-   r&   r'   rB   rK   z--namez-nz5Custom name for the server in Claude Desktop's config)r*   helpz--with-editablezVDirectory with pyproject.toml to install in editable mode (can be used multiple times) )rM   negativez--withz;Additional packages to install (can be used multiple times)z--envzFEnvironment variables in KEY=VALUE format (can be used multiple times)rL   z
--env-filez)Load environment variables from .env file)rM   r-   z--pythonz(Python version to use (e.g., 3.10, 3.11)z--with-requirementsz.Requirements file to install dependencies fromz	--projectz2Run the command within the given project directoryc                   #    U=(       d    / nU=(       d    / nU=(       d    / n[        XX4U5      I Sh  vN u  ppn[        U	U
UUUUUUUS9	nU(       d  [        R                  " S5        gg N87f)zxInstall an MCP server in Claude Desktop.

Args:
    server_spec: Python file to install, optionally with :object suffix
N)	r(   r)   r*   r"   r#   r$   r%   r&   r'   r
   )r   rJ   r   exit)rB   rK   r"   r#   r$   rL   r-   r&   r'   r(   r)   r*   env_dictsuccesss                 r   claude_desktop_commandrT   }   s     J "'RM!'RM~2H?R-8@ :6Dh %###+
G  !:s   2A/A-9A/)__doc__r   r   pathlibr   typingr   cycloptsrichr   fastmcp.mcp_configr   r   fastmcp.utilities.loggingr   6fastmcp.utilities.mcp_server_config.v1.environments.uvr	   sharedr   __name__loggerr    r8   listdictboolrJ   	ParameterrT    r!   r   <module>re      s   D 	 
     A 0 P '	H	t . (,&*&*!%%)T
T:T T
 :$T 9t#T 38nt#T $JT d{T D[T 
T@ 	 	 	 	 	 	 	 	{YY d
D!H	
	Y T
Ti	
	Y$ S	DN	
	%Y4 S	DY	
	5YD t<	
	EYR d
;	
	SY` !t!A	
	aYn tE	
	oY| 
}Yr!   