ó
    KùžjÐ  ã                   óì   • S r SSKrSSKrSSKrSSKrSSKrSSKJr  SSK	J
r
  SSKJr  \" \5      rSS\S\4S jjrS\S-  4S	 jrS\4S
 jrSSSS.S\S\S\S-  S\\   S-  S\\\4   S-  S\4S jjrg)z!Claude app integration utilities.é    N)ÚPath)ÚAny)Ú
get_loggerÚpackageÚreturnc                 ó¸   •  [         R                  R                  S5      nSU;   d  SU;   a  U $ U  SU 3$ ! [         R                  R                   a    U s $ f = f)u÷  Requirement string pinning spawned environments to the running SDK version.

`uv run --with mcp` resolves the requirement in a fresh environment, where
an unpinned `mcp` means the latest stable release â€” not necessarily the
version the user installed (pre-releases in particular are never selected
without an explicit pin). Source builds carry dev/local version segments
that are not published to PyPI, so they fall back to the unpinned form,
as does a missing distribution (no metadata to pin from).
Úmcpz.devÚ+z==)Ú	importlibÚmetadataÚversionÚPackageNotFoundError)r   r   s     ÚœC:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\mcp/cli/claude.pyÚmcp_requirementr      se   € ðÜ×$Ñ$×,Ñ,¨UÓ3ˆð �Ó˜C 7›NØˆØˆY�b˜˜	Ð"Ð"øô	 ×Ñ×2Ñ2ó ØŠðús   ‚6 ¶ AÁAc                  óÖ  • [         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    r   Ú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                  ól   • [         R                  " S5      n U (       d  [        R                  S5        gU $ )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,   3   s,   € ä�lŠl˜4Ó €GÞÜ�‰Øsô	
ð Ø€Nr$   )Úwith_editableÚwith_packagesÚenv_varsÚ	file_specÚserver_namer-   r.   r/   c                óú  • [        5       n[        5       nU(       d  [        S5      eUS-  nUR                  5       (       d   UR	                  SSS9   [        R                  " UR                  5       5      nS
U;  a  0 US
'   XS
   ;   a'  SUS
   U   ;   a  US
   U   S   n	U(       a  0 U	EUEnOU	nSS/n
[        S5      1nU(       a  UR                  S U 5       5        [        U5       H  nU
R                  SU/5        M     U(       a  U
R                  S[        U5      /5        [!        U 5      S:„  =(       a    U S   S:H  nSU(       a  U SS OU ;   a3  U R#                  SS5      u  pï[%        U5      R'                  5        SU 3n O"[        [%        U 5      R'                  5       5      n U
R                  SSU /5        XjS.nU(       a  UUS'   UUS
   U'   UR	                  [        R(                  " USS9SS9  [        R+                  SU S3S[        U5      0S9  g! [
         a"    [        R                  SS[        U5      0S9   g	f = f! [
         a"    [        R                  SS[        U5      0S9   g	f = f)ap  Add or update an MCP 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utf-8)Úencodingz#Failed to create Claude config fileÚconfig_file)ÚextraFÚ
mcpServersÚenvÚrunz--frozenzmcp[cli]c              3   ó6   #   • U  H  o(       d  M  Uv •  M     g 7f)N© )Ú.0Úpkgs     r   Ú	<genexpr>Ú'update_claude_config.<locals>.<genexpr>}   s   é € Ð@ª= C»CŸC™Cª=ùs   ‚
�	z--withz--with-editableé   Ú:é   Nr	   )Ú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_bytesr   ÚupdateÚsortedÚextendÚlenÚrsplitr   ÚresolveÚdumpsÚinfo)r0   r1   r-   r.   r/   Ú
config_dirr+   r4   ÚconfigÚexisting_envrC   Úpackagesr<   Úhas_windows_driveÚ	file_pathÚserver_objectÚserver_configs                    r   Úupdate_claude_configr]   >   sÁ  € ô, (Ó)€JÜ‹m€GÞÜðUó
ð 	
ð
 Ð;Ñ;€KØ×Ñ×Ñð		Ø×"Ñ" 4°'Ð"Ñ:ðAÜ—’˜K×2Ñ2Ó4Ó5ˆØ˜vÓ%Ø#%ˆF�<Ñ ð  Ñ.Ó.°5¸FÀ<Ñ<PÐQ\Ñ<]Ó3]Ø! ,Ñ/°Ñ<¸UÑCˆLÞà7˜lÐ7¨hÐ7‘à'�ð �zÐ"ˆô $ JÓ/Ð0ˆÞØ�O‰OÑ@©=Ó@Ô@ô ˜(Ö#ˆCØ�K‰K˜ 3˜Ö(ñ $ö Ø�K‰KÐ*¬C°Ó,>Ð?Ô@ô
   	›N¨QÑ.×F°9¸Q±<À3Ñ3FÐð Ö$5�9˜Q˜R‘=¸9ÓEØ'0×'7Ñ'7¸¸QÓ'?Ñ$ˆIÜ 	›?×2Ñ2Ó4Ð5°Q°}°oÐF‰IäœD ›O×3Ñ3Ó5Ó6ˆIð 	�‰�U˜E 9Ð-Ô.à4;Ñ(Jˆö Ø#+ˆM˜%Ñ à,9ˆˆ|Ñ˜[Ñ)à×ÑœtŸzšz¨&¸Ñ;ÀgÐÑNÜ�‰Ø˜[˜MÐ);Ð<Ø ¤# kÓ"2Ð3ð 	ñ 	
ð øôE ó 	Ü×ÑØ5à!¤3 {Ó#3ðð ñ ñ ð	ûôF ó Ü×ÑØ,àœs ;Ó/ðð 	ñ 	
ñ ðús%   ÁH ÁGI È)IÉ
IÉ)I:É9I:)r	   )Ú__doc__Úimportlib.metadatar   rJ   r   r'   r   Úpathlibr   Útypingr   Ú&mcp.server.mcpserver.utilities.loggingr   Ú__name__r)   rI   r   r#   r,   ÚlistÚdictÚboolr]   r:   r$   r   Ú<module>rg      sÂ   ðÙ 'ã Û Û 	Û Û 
Ý Ý å =á	�HÓ	€ñ#˜Sð #¨Sõ #ð&  t¡ô ð �Sô ð "&Ø&*Ø&*òlØðlàðlð ˜$‘;ð	lð
 ˜‘9˜tÑ#ðlð �3˜�8‰n˜tÑ#ðlð 
ölr$   