PrefectHQ/fastmcp · error · NotImplementedError

Component.enable() was removed in FastMCP 3.0. Use server.en

Error message

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

What it means

In FastMCP 3.0 the instance methods `Component.enable()`/`Component.disable()` were removed; enable/disable state is now managed centrally by the server via keys. Calling `component.enable()` raises NotImplementedError with a migration hint pointing at `server.enable(keys=[...])`.

Source

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

            return False
        return self.model_dump() == other.model_dump()

    def __repr__(self) -> str:
        parts = [f"name={self.name!r}"]
        if self.version:
            parts.append(f"version={self.version!r}")
        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.

View on GitHub (pinned to 1f02114297)

Solutions

  1. Replace `component.enable()` with `server.enable(keys=[component.key])`.
  2. Use server-level enable/disable APIs with component keys for runtime toggling.
  3. Pin FastMCP <3.0 only as a temporary measure while migrating.

Example fix

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

Strategy: try-catch

Validate before calling

def can_enable(component) -> bool:
    import inspect
    return not inspect.signature(type(component).enable).kwargs_eq if False else hasattr(component, 'key') and 'enable' in getattr(type(component), '__dict__', {}) is False or True

Try / catch

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

Prevention

When it happens

Trigger: Calling `tool.enable()`, `resource.enable()`, or `prompt.enable()` (or any FastMCPComponent subclass instance) after upgrading from FastMCP 2.x to 3.x.

Common situations: Code migrated from FastMCP 2.x where per-component enable() worked; tutorials or old snippets toggling components at runtime.

Related errors


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