
    Ki                     <   d Z ddlZddlZddlmZ ddlmZ ddlZddlZddl	m
Z
 ddlmZ ddlmZ dd	lmZ  ee      Zdddd
dddddededz  dedee   dz  dee   dz  deeef   dz  dededz  dedz  dedz  defdZdddddd
dddd	dedeedz   ej0                  ddgd      f   deee   dz   ej0                  dd d!"      f   deee   dz   ej0                  d#d$d!"      f   deee   dz   ej0                  d%d&d!"      f   d'eedz   ej0                  d(d)*      f   dee ej0                  d+d,d!"      f   d-eedz   ej0                  d.d/*      f   deedz   ej0                  d0d1*      f   deedz   ej0                  d2d3*      f   ddfd4Zy)5zEMCP configuration JSON generation for FastMCP install using Cyclopts.    N)Path)	Annotated)print)
get_logger)UVEnvironment   )process_common_argsF)with_editablewith_packagesenv_varscopypython_versionwith_requirementsprojectfileserver_objectnamer
   r   r   r   r   r   r   returnc                   	 t        ||xs g dgz   ||	|      }
|r| j                          d| }nt        | j                               }|
j                  dd|g      }|d   |dd d}|r||d	<   ||i}t	        j
                  |d
      }|r%t        j                  |       t        d| d       yt        |       y# t        $ r}t        d| d       Y d}~yd}~ww xY w)a  Generate MCP configuration JSON for manual installation.

    Args:
        file: Path to the server file
        server_object: Optional server object name (for :object suffix)
        name: Name for the server in MCP 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
        copy: If True, copy to clipboard instead of printing to stdout
        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 generation was successful, False otherwise
    fastmcp)pythondependenciesrequirementsr   editable:runr   r   N)commandargsenv   )indentz[green]MCP configuration for 'z' copied to clipboard[/green]Tz+[red]Failed to generate MCP configuration: z[/red]F)
r   resolvestrbuild_commandjsondumps	pyperclipr   r   	Exception)r   r   r   r
   r   r   r   r   r   r   
env_configserver_specfull_commandserver_configconfigjson_outputes                    h/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/fastmcp/cli/install/mcp_json.pyinstall_mcp_jsonr1      s   <-"!'-2)<*"

 !\\^,Am_=Kdlln-K "//E;0OP $A $
 #+M%  & jj2 NN;'24&8UVW
  + ;A3fEFs   B0B? 3B? ?	C!CC!)	server_namer
   r   r   env_filer   r   r   r   r*   r2   z--namez-nz(Custom name for the server in MCP config)r   helpz--with-editablezVDirectory with pyproject.toml to install in editable mode (can be used multiple times) )r4   negativez--withz;Additional packages to install (can be used multiple times)z--envzFEnvironment variables in KEY=VALUE format (can be used multiple times)r3   z
--env-filez)Load environment variables from .env file)r4   z--copyz=Copy configuration to clipboard instead of printing to stdoutr   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       	            K   |xs g }|xs g }|xs g }t        | ||||       d{   \  }
}}}}t        |
|||||||||	
      }|st        j                  d       yy7 8w)zGenerate MCP configuration JSON for manual installation.

    Args:
        server_spec: Python file to install, optionally with :object suffix
    N)
r   r   r   r
   r   r   r   r   r   r   r   )r	   r1   sysexit)r*   r2   r
   r   r   r3   r   r   r   r   r   r   r   packagesenv_dictsuccesss                   r0   mcp_json_commandr=   b   s     Z "'RM!'RM~2H:M[-8; 51D-x ##+G  #5s   %A"A 9A")__doc__r%   r8   pathlibr   typingr   cycloptsr'   richr   fastmcp.utilities.loggingr   6fastmcp.utilities.mcp_server_config.v1.environments.uvr   sharedr	   __name__loggerr#   listdictboolr1   	Parameterr=        r0   <module>rN      s$   K  
      0 P '	H	 (,&*&*!%%)K
K:K K
 :$K 9t#K 38nt#K K $JK d{K D[K 
Kn 	 	 	 	 	 	 	 	 	Kbb d
D!;	
	b T
Ti	
	b$ S	DN	
	%b4 S	DY	
	5bD t<	
	EbR P	
	Sbb d
;	
	cbp !t!A	
	qb~ tE	
	bL 
MbrM   