o
    i                     @   s  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B dedee dB dee dB deeef dB dededB dedB dedB defddZdddddd
dddd	dedeedB ejddgddf deee dB ejd d!d"d#f deee dB ejd$d%d"d#f deee dB ejd&d'd"d#f d(eedB ejd)d*d+f deeejd,d-d"d#f d.eedB ejd/d0d+f deedB ejd1d2d+f deedB ejd3d4d+f ddfd5d6ZdS )7zEMCP 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             
   C   s   z]t ||pg dg ||	|d}
|r|   d| }nt|  }|
dd|g}|d |dd d}|r:||d	< ||i}tj|d
d}|rWt| td| d W dS t| W dS  t	yx } ztd| d W Y d}~dS d}~w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e r.   b/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/fastmcp/cli/install/mcp_json.pyinstall_mcp_json   s<   

r0   )	server_namer	   r
   r   env_filer   r   r   r   r(   r1   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) )r3   negativez--withz;Additional packages to install (can be used multiple times)z--envzFEnvironment variables in KEY=VALUE format (can be used multiple times)r2   z
--env-filez)Load environment variables from .env file)r3   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       	            sl   |pg }|pg }|pg }t | ||||I dH \}
}}}}t|
|||||||||	d
}|s4td dS dS )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   r0   sysexit)r(   r1   r	   r
   r   r2   r   r   r   r   r   r   r   packagesenv_dictsuccessr.   r.   r/   mcp_json_commandb   s,   M
r;   )__doc__r#   r6   pathlibr   typingr   cycloptsr%   richr   fastmcp.utilities.loggingr   6fastmcp.utilities.mcp_server_config.v1.environments.uvr   sharedr   __name__loggerr!   listdictboolr0   	Parameterr;   r.   r.   r.   r/   <module>   s   

	

W



")18?F