
    iO*                        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
mZmZ d dlmZ d dlmZmZ d dlmZmZ d d	lmZ  ee      Z ej2                  d
d      Zed   Zed   ZdZ G d de      Z G d de      Zy)    )annotationsN)	timedelta)Path)	AnnotatedAnyLiteral)user_data_dir)Fieldfield_validator)BaseSettingsSettingsConfigDict)
get_loggerFASTMCP_ENV_FILEz.env)DEBUGINFOWARNINGERRORCRITICAL)warnerrorreplaceignorei   c                      e Zd ZU dZ edd      ZdZded<   dZd	ed
<   dZ	ded<   dZ
ded<    ed      Zded<    ed      Zded<   y)DocketSettingszDocket worker configuration.FASTMCP_DOCKET_r   )
env_prefixextrafastmcpzAnnotated[str, Field(description=inspect.cleandoc('\n                Name for the Docket queue. All servers/workers sharing the same name\n                and backend URL will share a task queue.\n                '))]namez	memory://a<  Annotated[str, Field(description=inspect.cleandoc('\n                URL for the Docket backend. Supports:\n                - memory:// - In-memory backend (single process only)\n                - redis://host:port/db - Redis/Valkey backend (distributed, multi-process)\n\n                Example: redis://localhost:6379/0\n\n                Default is memory:// for single-process scenarios. Use Redis or Valkey\n                when coordinating tasks across multiple processes (e.g., additional\n                workers via the fastmcp tasks CLI).\n                '))]urlNzAnnotated[str | None, Field(description=inspect.cleandoc('\n                Name for the Docket worker. If None, Docket will auto-generate\n                a unique worker name.\n                '))]worker_name
   zAnnotated[int, Field(description=inspect.cleandoc('\n                Maximum number of tasks the worker can process concurrently.\n                '))]concurrencyi,  )secondsa  Annotated[timedelta, Field(description=inspect.cleandoc("\n                Task redelivery timeout. If a worker doesn't complete\n                a task within this time, the task will be redelivered to another\n                worker.\n                "))]redelivery_timeout   zAnnotated[timedelta, Field(description=inspect.cleandoc('\n                Delay between reconnection attempts when the worker\n                loses connection to the Docket backend.\n                '))]reconnection_delay)__name__
__module____qualname____doc__r   model_configr   __annotations__r    r!   r#   r   r%   r'        `/Users/bowang/.openclaw/workspace/ChatDev/.venv/lib/python3.12/site-packages/fastmcp/settings.pyr   r      s    &%$L 	 	 
 
: 	#  
 : 	  
 
* 	  	 	, 	#   . 	!  
 
r/   r   c                  
   e Zd ZU dZ ededddd      ZdHdZdId	Z e	 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      ed               Z e       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)<   d*Zd+ed,<   d-Zded.<   d/Zded0<   d1Zded2<   dZ ded3<   dZ!d4ed5<   dZ"d6ed7<    e#e$d89      Z%d:ed;<   dZ&ded<<   dZ'ded=<   dZ(d>ed?<   dZ)d@edA<   dBZ*dCedD<   dEZ+dFedG<   y")JSettingszFastMCP settings.FASTMCP_r   __T)r   env_filer   env_nested_delimiter#nested_model_default_partial_updatevalidate_assignmentstrc                    | }d|v rA|j                  dd      \  }}t        ||      st        d| d      t        ||      }d|v rAt        ||      S )zz
        Get a setting. If the setting contains one or more `__`, it will be
        treated as a nested setting.
        r4      Setting  does not exist.)splithasattrAttributeErrorgetattr)selfattrsettingsparent_attrs       r0   get_settingzSettings.get_setting   sh    
 dl $

4 3K8[1$x}<L%MNNx5H	 dl
 x&&r/   c                    | }d|v rA|j                  dd      \  }}t        ||      st        d| d      t        ||      }d|v rAt	        |||       y)zz
        Set a setting. If the setting contains one or more `__`, it will be
        treated as a nested setting.
        r4   r;   r<   r=   N)r>   r?   r@   rA   setattr)rB   rC   valuerD   rE   s        r0   set_settingzSettings.set_setting   sg    
 dl $

4 3K8[1$x}<L%MNNx5H	 dl
 	$&r/   r   F)	appauthorr   homebool	test_modelog_enabledr   	LOG_LEVEL	log_levelbefore)modec                F    t        |t              r|j                         S |S )N)
isinstancer9   upper)clsvs     r0   normalize_log_levelzSettings.normalize_log_level   s     a779r/   r   docketzAnnotated[bool, Field(description=inspect.cleandoc('\n                If True, will use rich formatting for log output. If False,\n                will use standard Python logging without rich formatting.\n                '))]enable_rich_loggingzAnnotated[bool, Field(description=inspect.cleandoc('\n                If True, will use rich tracebacks for logging.\n                '))]enable_rich_tracebacksa_  Annotated[bool, Field(description=inspect.cleandoc("\n                Whether to show deprecation warnings. You can completely reset\n                Python's warning behavior by running `warnings.resetwarnings()`.\n                Note this will NOT apply to deprecation warnings from the\n                settings class itself.\n                "))]deprecation_warningsa  Annotated[bool, Field(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_errorNzAnnotated[float | None, Field(description="The timeout for the client's initialization handshake, in seconds. Set to None or 0 to disable.")]client_init_timeoutstdioz2Literal['stdio', 'http', 'sse', 'streamable-http']	transportz	127.0.0.1hosti@  intportz/ssesse_pathz
/messages/message_pathz/mcpstreamable_http_pathdebuga  Annotated[bool, Field(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_detailsa  Annotated[bool, Field(description=inspect.cleandoc('\n                If True, tool inputs are strictly validated against the input\n                JSON schema. For example, providing the string "10" to an\n                integer field will raise an error. If False, compatible inputs\n                will be coerced to match the schema, which can increase\n                compatibility. For example, providing the string "10" to an\n                integer field will be coerced to 10. Defaults to False.\n                '))]strict_input_validationz9List of dependencies to install in the server environment)default_factorydescriptionz	list[str]server_dependenciesjson_responsestateless_httpaE  Annotated[bool, Field(description=inspect.cleandoc('\n                If True, errors encountered when loading mounted components (tools, resources, prompts)\n                will be raised instead of logged as warnings. This is useful for debugging\n                but will interrupt normal operation.\n                '))]&mounted_components_raise_on_load_errora  Annotated[bool, Field(description=inspect.cleandoc('\n                If True, the server banner will be displayed when running the server.\n                This setting can be overridden by the --no-banner CLI flag or by\n                passing show_banner=False to server.run().\n                Set to False via FASTMCP_SHOW_SERVER_BANNER=false to suppress the banner.\n                '))]show_server_bannerstablea  Annotated[Literal['stable', 'prerelease', 'off'], Field(description=inspect.cleandoc('\n                Controls update checking when displaying the CLI banner.\n                - "stable": Check for stable releases only (default)\n                - "prerelease": Also check for pre-release versions (alpha, beta, rc)\n                - "off": Disable update checking entirely\n                Set via FASTMCP_CHECK_FOR_UPDATES environment variable.\n                '))]check_for_updatesfunctiona_  Annotated[Literal['function', 'object'], Field(description=inspect.cleandoc('\n                Controls what decorators (@tool, @resource, @prompt) return.\n\n                - "function" (default): Decorators return the original function unchanged.\n                  The function remains callable and is registered with the server normally.\n                - "object" (deprecated): Decorators return component objects (FunctionTool,\n                  FunctionResource, FunctionPrompt). This was the default behavior in v2 and\n                  will be removed in a future version.\n                '))]decorator_mode)rC   r9   returnr   )rC   r9   rI   r   rv   None),r(   r)   r*   r+   r   ENV_FILEr,   rF   rJ   r   r	   rL   r-   rN   rO   rQ   r   classmethodrY   r   rZ   r[   r\   r]   r^   r_   ra   rb   rd   re   rf   rg   rh   ri   rj   r
   listrm   rn   ro   rp   rq   rs   ru   r.   r/   r0   r2   r2   u   s   %!,0 L'' mI?@D$@ItK!Iy![x0  1
 ,-FN- 	  
 
* 	  	 	. 	   6 	 , . ( 	    ELIAK D#D#Hc$L#$ &#&E4  	   : 	     &+O&   M4 D  	 + - 2 	   6 	   < 	   r/   r2   ) 
__future__r   _annotationsinspectosdatetimer   pathlibr   typingr   r   r   platformdirsr	   pydanticr
   r   pydantic_settingsr   r   fastmcp.utilities.loggingr   r(   loggergetenvrx   rP   DuplicateBehaviorTEN_MB_IN_BYTESr   r2   r.   r/   r0   <module>r      s    2  	   * * & +
 1	H	299'0CD	@A "U\ Up`| `r/   