nat.plugins.fastmcp.cli.utils#

CLI helper utilities for FastMCP commands.

Attributes#

Functions#

_glob_matches(→ bool)

Return True when a path matches a glob pattern.

_filter_change_set(→ set[tuple[watchfiles.Change, str]])

Filter change events using include and exclude glob rules.

iter_file_changes(, exclude_globs, str]]])

Yield filtered file change sets using watchfiles with debounce.

Module Contents#

DEFAULT_RELOAD_EXCLUDE_GLOBS: tuple[str, Ellipsis] = ('*.log', '*.tmp', '*.temp')#
_glob_matches(path: str, pattern: str) bool#

Return True when a path matches a glob pattern.

Matching is performed against both the normalized full path and basename so patterns like *.py work regardless of directory depth.

_filter_change_set(
changes: set[tuple[watchfiles.Change, str]],
include_globs: tuple[str, Ellipsis],
exclude_globs: tuple[str, Ellipsis],
) set[tuple[watchfiles.Change, str]]#

Filter change events using include and exclude glob rules.

iter_file_changes(
paths: collections.abc.Iterable[pathlib.Path],
debounce_ms: int = 750,
include_globs: collections.abc.Iterable[str] = (),
exclude_globs: collections.abc.Iterable[str] = (),
) collections.abc.Iterator[set[tuple[watchfiles.Change, str]]]#

Yield filtered file change sets using watchfiles with debounce.

Parameters:
  • paths – File or directory paths to watch for changes.

  • debounce_ms – Debounce interval in milliseconds passed to watchfiles.

  • include_globs – Optional include patterns. When provided, only matching paths trigger reload checks.

  • exclude_globs – Optional exclude patterns. These are merged with DEFAULT_RELOAD_EXCLUDE_GLOBS only when include patterns are not provided.

Returns:

Iterator yielding sets of (Change, path) tuples that pass include/exclude filtering.