+
    Q(iD                         R t ^ RIHt ^ RIt^ RIHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt ]! ]4      t ! R R]4      tR# )a  FileSystemProvider for filesystem-based component discovery.

FileSystemProvider scans a directory for Python files, imports them, and
registers any Tool, Resource, ResourceTemplate, or Prompt objects found.

Components are created using the standalone decorators from fastmcp.tools,
fastmcp.resources, and fastmcp.prompts:

Example:
    ```python
    # In mcp/tools.py
    from fastmcp.tools import tool

    @tool
    def greet(name: str) -> str:
        return f"Hello, {name}!"

    # In main.py
    from pathlib import Path

    from fastmcp import FastMCP
    from fastmcp.server.providers import FileSystemProvider

    mcp = FastMCP("MyServer", providers=[FileSystemProvider(Path(__file__).parent / "mcp")])
    ```
)annotationsN)Sequence)Path)Prompt)Resource)ResourceTemplate)discover_and_import)LocalProvider)Tool)FastMCPComponent)
get_logger)VersionSpecc                    a  ] tR t^/tRtRR V 3R llltR R ltR R ltR R	 ltR
 V 3R llt	RR V 3R lllt
R V 3R lltRR V 3R llltR V 3R lltRR V 3R llltR V 3R lltRR V 3R llltR R ltRtV ;t# )FileSystemProvideraJ  Provider that discovers components from the filesystem.

Scans a directory for Python files and registers any Tool, Resource,
ResourceTemplate, or Prompt objects found. Components are created using
the standalone decorators:
- @tool from fastmcp.tools
- @resource from fastmcp.resources
- @prompt from fastmcp.prompts

Args:
    root: Root directory to scan. Defaults to current directory.
    reload: If True, re-scan files on every request (dev mode).
        Defaults to False (scan once at init, cache results).

Example:
    ```python
    # In mcp/tools.py
    from fastmcp.tools import tool

    @tool
    def greet(name: str) -> str:
        return f"Hello, {name}!"

    # In main.py
    from pathlib import Path

    from fastmcp import FastMCP
    from fastmcp.server.providers import FileSystemProvider

    # Path relative to this file
    mcp = FastMCP("MyServer", providers=[FileSystemProvider(Path(__file__).parent / "mcp")])

    # Dev mode - re-scan on every request
    mcp = FastMCP("MyServer", providers=[FileSystemProvider(Path(__file__).parent / "mcp", reload=True)])
    ```
c               $    V ^8  d   QhRRRRRR/# )   rootz
str | PathreloadboolreturnNone )formats   "i/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/server/providers/filesystem.py__annotate__FileSystemProvider.__annotate__U   s(            
	     c                	   < \         SV `  R R7       \        V4      P                  4       V n        W n        RV n        / V n        RV n        V P                  4        R# )replace)on_duplicateFN)
super__init__r   resolve_root_reload_loaded_warned_files_reload_lock_load_components)selfr   r   	__class__s   &&&r   r!   FileSystemProvider.__init__U   sU    
 	i0$Z'')
 1315 	r   c                   V ^8  d   QhRR/# r   r   r   r   )r   s   "r   r   r   g   s     '
 '
$ '
r   c                   V P                   '       d   V P                  P                  4        \        V P                  4      pVP
                  P                  4        Fp  w  r# VP                  4       P                  pV P                  P                  V4      pVe	   WT8w  g   KG  \        P                  RV RV 24       W@P                  V&   Kr  	  VP                   UUu0 uF  w  rgVkK	  	  pppV F  pV P                  P                  VR4       K!  	  VP                   F  w  r) V P!                  V	4       K  	  RV n         \        P+                  R\-        V P                  4       R	V P                   24       R#   \         d    Rp ELi ; iu uppi   \"         d0    \        P%                  R\'        T	R\)        T	4      4      T4        K  i ; i)
z9Discover and register all components from the filesystem.g        NzFailed to import z: zFailed to register %s from %snameTzFileSystemProvider loaded z components from )r%   _componentsclearr   r#   failed_filesitemsstatst_mtimeOSErrorr&   getloggerwarning
componentspop_register_component	Exception	exceptiongetattrreprdebuglen)
r)   result	file_patherrorcurrent_mtimelast_warned_mtimefp_successful_files	components
   &         r   r(   #FileSystemProvider._load_componentsg   s    <<<""$$TZZ0 !' 3 3 9 9 ;I$ ) 0 9 9
 !% 2 2 6 6y A (,=,N!29+RwGH0=""9- !< -3,=,=>,=52B,=>"B""2t, # %+$5$5 I((3 %6 (T-=-=)>(??PQUQ[Q[P\]	
3  $ #$ ?    3IvtI?s*   "E<F&F<FF6GGc                    V ^8  d   QhRRRR/# )r   rK   r   r   r   r   )r   s   "r   r   r      s     Q Q-= Q$ Qr   c                   \        V\        4      '       d   V P                  V4       R# \        V\        4      '       d   V P	                  V4       R# \        V\
        4      '       d   V P                  V4       R# \        V\        4      '       d   V P                  V4       R# \        P                  R\        V4      4       R# )z.Register a single component based on its type.z#Ignoring unknown component type: %rN)
isinstancer
   add_toolr   add_templater   add_resourcer   
add_promptr8   rA   type)r)   rK   s   &&r   r<   &FileSystemProvider._register_component   s~    i&&MM)$	#344i(	8,,i(	6**OOI&LL>YPr   c                   V ^8  d   QhRR/# r-   r   )r   s   "r   r   r      s     ? ?d ?r   c                  "   V P                   '       g   V P                  '       d   R# V P                  f   \        P                  ! 4       V n        V P                  ;_uu_4       GRj  xL
  V P                   '       g   V P                  '       g)   \        P
                  ! V P                  4      G Rj  xL
  RRR4      GRj  xL
  R#  Lb L L
  + GRj  xL 
 '       g   i     R# ; i5i)zEnsure components are loaded, reloading if in reload mode.

Uses a lock to serialize concurrent reload operations and runs
filesystem I/O off the event loop using asyncio.to_thread.
N)r$   r%   r'   asyncioLock	to_threadr(   r)   s   &r   _ensure_loaded!FileSystemProvider._ensure_loaded   s      ||| $ 'D$$$$|||4<<<''(=(=>>> %$$ ? %$$$sk   $C/AC/)C*C/-$C#C5C6C:C/CC/CC/C,	C
C,	$C,	&	C/c                   V ^8  d   QhRR/# )r   r   zSequence[Tool]r   )r   s   "r   r   r      s     + +> +r   c                p   <"   V P                  4       G Rj  xL
  \        SV `	  4       G Rj  xL
 #  L L5i)z.Return all tools, reloading if in reload mode.N)r\   r    _list_toolsr)   r*   s   &r   r`   FileSystemProvider._list_tools   s1     !!###W(*** 	$*   626466c               $    V ^8  d   QhRRRRRR/# )r   r/   strversionVersionSpec | Noner   zTool | Noner   )r   s   "r   r   r      s$     6 66"46	6r   c                r   <"   V P                  4       G Rj  xL
  \        SV `	  W4      G Rj  xL
 #  L L5i)z0Get a tool by name, reloading if in reload mode.N)r\   r    	_get_toolr)   r/   rf   r*   s   &&&r   ri   FileSystemProvider._get_tool   s5      !!###W&t555 	$5   737577c                   V ^8  d   QhRR/# )r   r   zSequence[Resource]r   )r   s   "r   r   r      s     / /'9 /r   c                p   <"   V P                  4       G Rj  xL
  \        SV `	  4       G Rj  xL
 #  L L5i)z2Return all resources, reloading if in reload mode.N)r\   r    _list_resourcesra   s   &r   ro   "FileSystemProvider._list_resources   s1     !!###W,... 	$.rc   c               $    V ^8  d   QhRRRRRR/# )r   urire   rf   rg   r   zResource | Noner   )r   s   "r   r   r      s$     9 99!39	9r   c                r   <"   V P                  4       G Rj  xL
  \        SV `	  W4      G Rj  xL
 #  L L5i)z3Get a resource by URI, reloading if in reload mode.N)r\   r    _get_resourcer)   rr   rf   r*   s   &&&r   rt    FileSystemProvider._get_resource   s5      !!###W*3888 	$8rl   c                   V ^8  d   QhRR/# )r   r   zSequence[ResourceTemplate]r   )r   s   "r   r   r      s     8 80J 8r   c                p   <"   V P                  4       G Rj  xL
  \        SV `	  4       G Rj  xL
 #  L L5i)z;Return all resource templates, reloading if in reload mode.N)r\   r    _list_resource_templatesra   s   &r   ry   +FileSystemProvider._list_resource_templates   s1     !!###W5777 	$7rc   c               $    V ^8  d   QhRRRRRR/# )r   rr   re   rf   rg   r   zResourceTemplate | Noner   )r   s   "r   r   r      s)     B BB!3B	 Br   c                r   <"   V P                  4       G Rj  xL
  \        SV `	  W4      G Rj  xL
 #  L L5i)z5Get a resource template, reloading if in reload mode.N)r\   r    _get_resource_templateru   s   &&&r   r}   )FileSystemProvider._get_resource_template   s5      !!###W3CAAA 	$Arl   c                   V ^8  d   QhRR/# )r   r   zSequence[Prompt]r   )r   s   "r   r   r      s     - -%5 -r   c                p   <"   V P                  4       G Rj  xL
  \        SV `	  4       G Rj  xL
 #  L L5i)z0Return all prompts, reloading if in reload mode.N)r\   r    _list_promptsra   s   &r   r    FileSystemProvider._list_prompts   s1     !!###W*,,, 	$,rc   c               $    V ^8  d   QhRRRRRR/# )r   r/   re   rf   rg   r   zPrompt | Noner   )r   s   "r   r   r      s$     8 88"48	8r   c                r   <"   V P                  4       G Rj  xL
  \        SV `	  W4      G Rj  xL
 #  L L5i)z2Get a prompt by name, reloading if in reload mode.N)r\   r    _get_promptrj   s   &&&r   r   FileSystemProvider._get_prompt   s5      !!###W(777 	$7rl   c                   V ^8  d   QhRR/# )r   r   re   r   )r   s   "r   r   r      s     Q Q# Qr   c                	>    R V P                   : RV P                   R2# )zFileSystemProvider(root=z	, reload=))r#   r$   r[   s   &r   __repr__FileSystemProvider.__repr__   s    )$**yaPPr   )r%   r$   r'   r#   r&   ).F)N)__name__
__module____qualname____firstlineno____doc__r!   r(   r<   r\   r`   ri   ro   rt   ry   r}   r   r   r   __static_attributes____classcell__)r*   s   @r   r   r   /   s    #J   $'
RQ?(+ +
6 6/ /
9 98 8
B B- -
8 8Q Qr   r   )r   
__future__r   rX   collections.abcr   pathlibr   fastmcp.prompts.promptr   fastmcp.resources.resourcer   fastmcp.resources.templater   -fastmcp.server.providers.filesystem_discoveryr   'fastmcp.server.providers.local_providerr	   fastmcp.tools.toolr
   fastmcp.utilities.componentsr   fastmcp.utilities.loggingr   fastmcp.utilities.versionsr   r   r8   r   r   r   r   <module>r      sM   6 #  $  ) / 7 M A # 9 0 2	H	sQ sQr   