fastmcp.server.providers.filesystem_discovery
File discovery and module import utilities for filesystem-based routing.
This module provides functions to:
- Discover Python files in a directory tree
- Import modules (as packages if init.py exists, else directly)
- Extract decorated components (Tool, Resource, Prompt objects) from imported modules
Functions
discover_files
root: Root directory to scan.
- List of .py file paths, sorted for deterministic order.
import_module_from_file
file_path: Path to the Python file.
- The imported module.
ImportError: If the module cannot be imported.
extract_components
module: The imported module to scan.
- List of component objects (Tool, Resource, ResourceTemplate, Prompt).
discover_and_import
root: Root directory to scan.
- DiscoveryResult with components and any failed files.

