Ë
    ïñþiÞ  ã                   óÊ   — d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
  e
e«      ZdZdedz  fd„Zdefd	„Zdddd
œdedededz  dee   dz  deeef   dz  defd„Zy)z!Claude app integration utilities.é    N)ÚPath)ÚAny)Ú
get_loggerzmcp[cli]Úreturnc                  ó¸  — t         j                  dk(  r!t        t        j                  «       ddd«      } n”t         j                  dk(  r!t        t        j                  «       ddd«      } n`t         j                  j	                  d«      r@t        t
        j                  j                  d	t        j                  «       d
z  «      d«      } ny| j                  «       r| S y)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    úN/root/aria/mcps/aria-brain/venv/lib/python3.12/site-packages/mcp/cli/claude.pyÚget_claude_config_pathr      s•   € ä
‡|�|�wÒÜ”D—I‘I“K ¨I°xÓ@‰Ü	�‰˜Ò	!Ü”D—I‘I“K Ð,AÀ8ÓL‰Ü	�‰×	 Ñ	  Ô	)Ü”B—J‘J—N‘NÐ#4´d·i±i³kÀIÑ6MÓNÐPXÓY‰àà‡{�{„}ØˆØó    c                  ó`   — t        j                  d«      } | st        j                  d«       y| S )z'Get the full path to the uv executable.Úuvzeuv executable not found in PATH, falling back to 'uv'. Please ensure uv is installed and in your PATH)ÚshutilÚwhichÚloggerÚerror)Úuv_paths    r   Úget_uv_pathr#   !   s,   € ä�l‰l˜4Ó €GÙÜ�‰Øsô	
ð Ø€Nr   )Úwith_editableÚwith_packagesÚenv_varsÚ	file_specÚserver_namer$   r%   r&   c                óh  — t        «       }t        «       }|st        d«      ‚|dz  }|j                  «       s	 |j	                  d«       	 t        j                  |j                  «       «      }d|vri |d<   ||d   v r d	|d   |   v r|d   |   d	   }	|ri |	¥|¥}n|	}d
dg}
t        h}|r|j                  d„ |D «       «       t        |«      D ]  }|
j                  d|g«       Œ |r|
j                  dt        |«      g«       d| v r4| j!                  dd«      \  }}t#        |«      j%                  «       › d|› �} n"t        t#        | «      j%                  «       «      } |
j                  dd
| g«       ||
dœ}|r||d	<   ||d   |<   |j	                  t        j&                  |d¬«      «       t        j)                  d|› d�dt        |«      i¬«       y# t
        $ r% t        j                  ddt        |«      i¬«       Y yw xY w# t
        $ r% t        j                  ddt        |«      i¬«       Y yw xY w)aŸ  Add or update a FastMCP server in Claude's configuration.

    Args:
        file_spec: Path to the server file, optionally with :object suffix
        server_name: Name for the server in Claude's config
        with_editable: Optional directory to install in editable mode
        with_packages: Optional list of additional packages to install
        env_vars: Optional dictionary of environment variables. These are merged with
            any existing variables, with new values taking precedence.

    Raises:
        RuntimeError: If Claude Desktop's config directory is not found, indicating
            Claude Desktop may not be installed or properly set up.
    z�Claude Desktop config directory not found. Please ensure Claude Desktop is installed and has been run at least once to initialize its config.zclaude_desktop_config.jsonz{}z#Failed to create Claude config fileÚconfig_file)ÚextraFÚ
mcpServersÚenvÚrunz--frozenc              3   ó&   K  — | ]	  }|sŒ|–— Œ y ­w)N© )Ú.0Úpkgs     r   ú	<genexpr>z'update_claude_config.<locals>.<genexpr>k   s   è ø€ Ò@ CºCœCÑ@ùs   ‚Šz--withz--with-editableú:é   Úmcp)ÚcommandÚargsé   )ÚindentzAdded server 'z' to Claude configTzFailed to update Claude config)r   r#   ÚRuntimeErrorr   Ú
write_textÚ	Exceptionr    Ú	exceptionÚstrÚjsonÚloadsÚ	read_textÚMCP_PACKAGEÚupdateÚsortedÚextendÚrsplitr   ÚresolveÚdumpsÚinfo)r'   r(   r$   r%   r&   Ú
config_dirr"   r*   ÚconfigÚexisting_envr8   Úpackagesr2   Ú	file_pathÚserver_objectÚserver_configs                   r   Úupdate_claude_configrR   ,   sŽ  € ô, (Ó)€JÜ‹m€GÙÜðUó
ð 	
ð
 Ð;Ñ;€KØ×ÑÔð		Ø×"Ñ" 4Ô(ð=Ü—‘˜K×1Ñ1Ó3Ó4ˆØ˜vÑ%Ø#%ˆF�<Ñ ð ˜& Ñ.Ñ.°5¸FÀ<Ñ<PÐQ\Ñ<]Ñ3]Ø! ,Ñ/°Ñ<¸UÑCˆLÙà7˜lÐ7¨hÐ7‘à'�ð �zÐ"ˆô  �=ˆÙØ�O‰OÑ@¨=Ô@Ô@ô ˜(Ó#ò 	)ˆCØ�K‰K˜ 3˜Õ(ð	)ñ Ø�K‰KÐ*¬C°Ó,>Ð?Ô@ð �)ÑØ'0×'7Ñ'7¸¸QÓ'?Ñ$ˆI�}Ü 	›?×2Ñ2Ó4Ð5°Q°}°oÐF‰IäœD ›O×3Ñ3Ó5Ó6ˆIð 	�‰�U˜E 9Ð-Ô.à4;ÀTÑ(Jˆñ Ø#+ˆM˜%Ñ à,9ˆˆ|Ñ˜[Ñ)à×ÑœtŸz™z¨&¸Ô;Ô<Ü�‰Ø˜[˜MÐ);Ð<Ø ¤# kÓ"2Ð3ð 	ô 	
ð øô} ò 	Ü×ÑØ5à!¤3 {Ó#3ðð ô ñ ð	ûô~ ò Ü×ÑØ,àœs ;Ó/ðð 	ô 	
ñ ðús$   ¸G Á
FH Ç+H Ç?H È+H1È0H1)Ú__doc__r@   r   r   r   Úpathlibr   Útypingr   Ú$mcp.server.fastmcp.utilities.loggingr   Ú__name__r    rC   r   r?   r#   ÚlistÚdictÚboolrR   r0   r   r   ú<module>r[      s±   ðÙ 'ã Û 	Û Û 
Ý Ý å ;á	�HÓ	€à€ð  t¡ó ð �Só ð "&Ø&*Ø&*òhØðhàðhð ˜$‘;ð	hð
 ˜‘9˜tÑ#ðhð �3˜�8‰n˜tÑ#ðhð 
ôhr   