PrefectHQ/fastmcp · error · NotImplementedError

Component.disable() was removed in FastMCP 3.0. Use server.d

Error message

Component.disable() was removed in FastMCP 3.0. Use server.disable(keys=['{self.key}']) instead.

What it means

The counterpart of enable(): `Component.disable()` was removed in FastMCP 3.0 and raises NotImplementedError directing users to `server.disable(keys=['<component key>'])`. Disable state is managed by the server, not by mutating components in place.

Source

Thrown at fastmcp_slim/fastmcp/utilities/components.py:218

        parts.extend(
            [
                f"title={self.title!r}",
                f"description={self.description!r}",
                f"tags={self.tags}",
            ]
        )
        return f"{self.__class__.__name__}({', '.join(parts)})"

    def enable(self) -> None:
        """Removed in 3.0. Use server.enable(keys=[...]) instead."""
        raise NotImplementedError(
            f"Component.enable() was removed in FastMCP 3.0. "
            f"Use server.enable(keys=['{self.key}']) instead."
        )

    def disable(self) -> None:
        """Removed in 3.0. Use server.disable(keys=[...]) instead."""
        raise NotImplementedError(
            f"Component.disable() was removed in FastMCP 3.0. "
            f"Use server.disable(keys=['{self.key}']) instead."
        )

    def copy(self) -> Self:  # type: ignore[override]  # ty:ignore[invalid-method-override]
        """Create a copy of the component."""
        return self.model_copy()

    def get_span_attributes(self) -> dict[str, Any]:
        """Return span attributes for telemetry.

        Subclasses should call super() and merge their specific attributes.
        """
        return {"fastmcp.component.key": self.key}

View on GitHub (pinned to 1f02114297)

Solutions

  1. Replace with `server.disable(keys=[component.key])`.
  2. Manage enabled/disabled state through the server API keyed by component.key.
  3. Audit code for `.disable()` calls after upgrading to 3.0.

Example fix

// before
tool.disable()
// after
mcp.disable(keys=[tool.key])
Defensive patterns

Strategy: try-catch

Try / catch

try:
    tool.disable()
except NotImplementedError:
    mcp.disable(keys=[tool.key])

Prevention

When it happens

Trigger: Calling `component.disable()` on any FastMCPComponent (tool, resource, template, prompt) under FastMCP 3.x.

Common situations: 2.x-era runtime feature-flag code disabling tools conditionally; copied examples using per-component disable.

Related errors


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