
    ~h!                        d dl mZ d dlZd dlZd dlmZ d dlmZm	Z	m
Z
 d dlmZmZ d dlmZ d dlmZmZmZmZ d dlmZ e
d	   Ze
d
   Z G d de      Z G d ded      Z G d de      Z e       Zy)    )annotationsN)Path)	AnnotatedAnyLiteral)Fieldmodel_validator)	FieldInfo)BaseSettingsEnvSettingsSourcePydanticBaseSettingsSourceSettingsConfigDict)Self)DEBUGINFOWARNINGERRORCRITICAL)warnerrorreplaceignorec                  0     e Zd ZdZ	 	 	 	 	 	 d fdZ xZS )ExtendedEnvSettingsSourcez
    A special EnvSettingsSource that allows for multiple env var prefixes to be used.

    Raises a deprecation warning if the old `FASTMCP_SERVER_` prefix is used.
    c                    | j                   j                  d      x}rL|D ]G  }|| _        t        |   ||      \  }}}|!|dk(  rt        j                  dt        d       |||fc S  t        |   ||      S )Nenv_prefixesFASTMCP_SERVER_zTUsing `FASTMCP_SERVER_` environment variables is deprecated. Use `FASTMCP_` instead.   
stacklevel)configget
env_prefixsuperget_field_valuewarningsr   DeprecationWarning)	selffield
field_nameprefixesprefixenv_val	field_keyvalue_is_complex	__class__s	           L/opt/mcp/mcp-sentiment/venv/lib/python3.12/site-packages/fastmcp/settings.pyr%   z)ExtendedEnvSettingsSource.get_field_value   s     {{~6686" @"(7<w7N:84$4 &!22 r.'(
 #I/???@ w&uj99    )r)   r
   r*   strreturnztuple[Any, str, bool])__name__
__module____qualname____doc__r%   __classcell__)r0   s   @r1   r   r      s*    ::,/:	: :r2   r   c                      e Zd ZU ded<   y)ExtendedSettingsConfigDictzlist[str] | Noner   N)r5   r6   r7   __annotations__ r2   r1   r;   r;   4   s    ""r2   r;   F)totalc                     e Zd ZU dZ eddgdddd      Ze	 	 	 	 	 	 	 	 	 	 	 	 d<d	       Zed=d
       Z	 e
j                         dz  Zded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<    ed !      d=d"       Zd#Zd$ed%<   d&Zd'ed(<   d)Zd$ed*<   d+Zd$ed,<   d-Zd$ed.<   dZded/<   dZd0ed1<   g Zd2ed3<   dZded4<   dZded5<   dZ d6ed7<   dZ!d8ed9<   dZ"d:ed;<   y)>SettingszFastMCP settings.FASTMCP_r   z.envr   __T)r   env_fileextraenv_nested_delimiter#nested_model_default_partial_updatec                     |t        |      ||fS )N)r   )clssettings_clsinit_settingsenv_settingsdotenv_settingsfile_secret_settingss         r1   settings_customise_sourcesz#Settings.settings_customise_sourcesC   s     %l3 	
 	
r2   c                >    t        j                  dt        d       | S )z
        This property is for backwards compatibility with FastMCP < 2.8.0,
        which accessed fastmcp.settings.settings
        zLUsing fastmcp.settings.settings is deprecated. Use fastmcp.settings instead.r   r   )r&   r   r'   )r(   s    r1   settingszSettings.settingsU   s      	Z	

 r2   z.fastmcpr   homeFbool	test_moder   	LOG_LEVEL	log_levelzAnnotated[bool, Field(description=inspect.cleandoc('\n                If True, will use rich tracebacks for logging.\n                '))]enable_rich_tracebacksa  Annotated[bool, Field(default=True, description=inspect.cleandoc('\n                Many MCP components operate in anyio taskgroups, and raise\n                ExceptionGroups instead of exceptions. If this setting is True, FastMCP Clients\n                will `raise` the first error in any ExceptionGroup instead of raising\n                the ExceptionGroup as a whole. This is useful for debugging, but may\n                mask other errors.\n                '))]'client_raise_first_exceptiongroup_errorpatha  Annotated[Literal['protocol', 'path'], Field(default='path', description=inspect.cleandoc('\n                When perfixing a resource URI, either use path formatting (resource://prefix/path)\n                or protocol formatting (prefix+resource://path). Protocol formatting was the default in FastMCP < 2.4;\n                path formatting is current default.\n                '))]resource_prefix_formata)  Annotated[bool, Field(default=False, description=inspect.cleandoc('\n                Note: this enables a legacy behavior. If True, will attempt to parse\n                stringified JSON lists and objects strings in tool arguments before\n                passing them to the tool. This is an old behavior that can create\n                unexpected type coercion issues, but may be helpful for less powerful\n                LLMs that stringify JSON instead of passing actual lists and objects.\n                Defaults to False.\n                '))]tool_attempt_parse_json_argsNzAnnotated[float | None, Field(description="The timeout for the client's initialization handshake, in seconds. Set to None or 0 to disable.")]client_init_timeoutafter)modec                N    ddl m}  || j                  | j                         | S )zFinalize the settings.r   )configure_logging)rV   )fastmcp.utilities.loggingr_   rU   rV   )r(   r_   s     r1   setup_loggingzSettings.setup_logging   s&     	@NN43N3N	
 r2   z	127.0.0.1r3   hosti@  intportz/ssesse_pathz
/messages/message_pathz/mcpstreamable_http_pathdebuga  Annotated[bool, Field(default=False, description=inspect.cleandoc('\n                If True, error details from user-supplied functions (tool, resource, prompt)\n                will be masked before being sent to clients. Only error messages from explicitly\n                raised ToolError, ResourceError, or PromptError will be included in responses.\n                If False (default), all error details will be included in responses, but prefixed\n                with appropriate context.\n                '))]mask_error_detailszzAnnotated[list[str], Field(default_factory=list, description='List of dependencies to install in the server environment')]server_dependenciesjson_responsestateless_httpa	  Annotated[Literal['bearer_env'] | None, Field(description=inspect.cleandoc('\n                Configure the authentication provider. This setting is intended only to\n                be used for remote confirugation of providers that fully support\n                environment variable configuration.\n\n                If None, no automatic configuration will take place.\n\n                This setting is *always* overriden by any auth provider passed to the\n                FastMCP constructor.\n                '))]default_auth_providera=  Annotated[set[str] | None, Field(default=None, description=inspect.cleandoc('\n                If provided, only components that match these tags will be\n                exposed to clients. A component is considered to match if ANY of\n                its tags match ANY of the tags in the set.\n                '))]include_tagsa>  Annotated[set[str] | None, Field(default=None, description=inspect.cleandoc('\n                If provided, components that match these tags will be excluded\n                from the server. A component is considered to match if ANY of\n                its tags match ANY of the tags in the set.\n                '))]exclude_tags)rI   ztype[BaseSettings]rJ   r   rK   r   rL   r   rM   r   r4   z&tuple[PydanticBaseSettingsSource, ...])r4   r   )#r5   r6   r7   r8   r;   model_configclassmethodrN   propertyrP   r   rQ   r<   rS   rU   rV   rW   rY   rZ   r[   r	   ra   rb   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   r=   r2   r1   r@   r@   8   s   - "34!,0L 
(
 2
 1	

 4
 9
 
0
 
"   z)D$)It!Iy! 	  	 	2 	 , . 8 	   : 	 ! # , 	    '" # D#D#Hc$L#$ &#&E4" 	   , 	     M4 D * 	!   < 	   2 	   r2   r@   )
__future__r   _annotationsinspectr&   pathlibr   typingr   r   r   pydanticr   r	   pydantic.fieldsr
   pydantic_settingsr   r   r   r   typing_extensionsr   rT   DuplicateBehaviorr   r;   r@   rP   r=   r2   r1   <module>r}      sw    2    * * + %  #CD	@A : 1 ::#!35 #N| Nb :r2   