PrefectHQ/fastmcp · error · AttributeError

Setting {parent_attr} does not exist.

Error message

Setting {parent_attr} does not exist.

What it means

Settings.get_setting resolves dotted `__`-joined attribute paths (e.g. `server__host`) by walking parent objects. If an intermediate parent segment doesn't exist as an attribute on the current settings object, an AttributeError is raised naming the missing parent. This guards against typos and renamed nested setting groups.

Source

Thrown at fastmcp_slim/fastmcp/settings.py:55

    model_config = SettingsConfigDict(
        env_prefix="FASTMCP_",
        env_file=ENV_FILE,
        extra="ignore",
        env_nested_delimiter="__",
        nested_model_default_partial_update=True,
        validate_assignment=True,
    )

    def get_setting(self, attr: str) -> Any:
        """
        Get a setting. If the setting contains one or more `__`, it will be
        treated as a nested setting.
        """
        settings = self
        while "__" in attr:
            parent_attr, attr = attr.split("__", 1)
            if not hasattr(settings, parent_attr):
                raise AttributeError(f"Setting {parent_attr} does not exist.")
            settings = getattr(settings, parent_attr)
        return getattr(settings, attr)

    def set_setting(self, attr: str, value: Any) -> None:
        """
        Set a setting. If the setting contains one or more `__`, it will be
        treated as a nested setting.
        """
        settings = self
        while "__" in attr:
            parent_attr, attr = attr.split("__", 1)
            if not hasattr(settings, parent_attr):
                raise AttributeError(f"Setting {parent_attr} does not exist.")
            settings = getattr(settings, parent_attr)
        setattr(settings, attr, value)

    home: Path = Path(user_data_dir("fastmcp", appauthor=False))

View on GitHub (pinned to 1f02114297)

Solutions

  1. Check spelling of the parent segment against the current Settings class attributes.
  2. After upgrading FastMCP, update paths whose parent group was renamed or removed (check the changelog / settings docs).
  3. Use `hasattr(settings, parent)` in code that resolves user-supplied paths dynamically before calling get_setting.

Example fix

# before
value = get_setting("servr__host")  # typo
# after
value = get_setting("server__host")
Defensive patterns

Strategy: validation

Validate before calling

def get_setting_safe(settings, attr):
    parts = attr.split("__")
    obj = settings
    for p in parts[:-1]:
        if not hasattr(obj, p):
            raise AttributeError(f"Unknown settings path: {attr}")
        obj = getattr(obj, p)
    if not hasattr(obj, parts[-1]):
        raise AttributeError(f"Unknown setting: {attr}")
    return getattr(obj, parts[-1])

Try / catch

try:
    value = settings.get_setting("server__host")
except AttributeError as e:
    log.error(f"Bad settings path: {e}")
    value = DEFAULTS["server__host"]

Prevention

When it happens

Trigger: Calling `get_setting("foo__bar")` where `foo` is not an attribute of the Settings object — e.g. a typo like `temp__dir` instead of `temporary_settings__...`, or referencing a nested group removed/renamed in a newer FastMCP version.

Common situations: Environment-driven config strings built by concatenation; referencing settings names from outdated docs after an upgrade renamed a nested group; typos in the `__` path prefix.

Related errors


AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29). Data as JSON: /api/errors/dcb944d61ba3430d. Report an issue: GitHub.