{"record":{"id":"4c7616401d8f82b3","repo":"PrefectHQ/fastmcp","slug":"component-enable-was-removed-in-fastmcp-3-0-use","errorCode":null,"errorMessage":"Component.enable() was removed in FastMCP 3.0. Use server.enable(keys=['{self.key}']) instead.","messagePattern":"Component\\.enable\\(\\) was removed in FastMCP 3\\.0\\. Use server\\.enable\\(keys=\\['(.+?)'\\]\\) instead\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/utilities/components.py","lineNumber":211,"sourceCode":"            return False\n        return self.model_dump() == other.model_dump()\n\n    def __repr__(self) -> str:\n        parts = [f\"name={self.name!r}\"]\n        if self.version:\n            parts.append(f\"version={self.version!r}\")\n        parts.extend(\n            [\n                f\"title={self.title!r}\",\n                f\"description={self.description!r}\",\n                f\"tags={self.tags}\",\n            ]\n        )\n        return f\"{self.__class__.__name__}({', '.join(parts)})\"\n\n    def enable(self) -> None:\n        \"\"\"Removed in 3.0. Use server.enable(keys=[...]) instead.\"\"\"\n        raise NotImplementedError(\n            f\"Component.enable() was removed in FastMCP 3.0. \"\n            f\"Use server.enable(keys=['{self.key}']) instead.\"\n        )\n\n    def disable(self) -> None:\n        \"\"\"Removed in 3.0. Use server.disable(keys=[...]) instead.\"\"\"\n        raise NotImplementedError(\n            f\"Component.disable() was removed in FastMCP 3.0. \"\n            f\"Use server.disable(keys=['{self.key}']) instead.\"\n        )\n\n    def copy(self) -> Self:  # type: ignore[override]  # ty:ignore[invalid-method-override]\n        \"\"\"Create a copy of the component.\"\"\"\n        return self.model_copy()\n\n    def get_span_attributes(self) -> dict[str, Any]:\n        \"\"\"Return span attributes for telemetry.\n","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/utilities/components.py#L193-L229","documentation":"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=[...])`.","triggerScenarios":"Calling `tool.enable()`, `resource.enable()`, or `prompt.enable()` (or any FastMCPComponent subclass instance) after upgrading from FastMCP 2.x to 3.x.","commonSituations":"Code migrated from FastMCP 2.x where per-component enable() worked; tutorials or old snippets toggling components at runtime.","solutions":["Replace `component.enable()` with `server.enable(keys=[component.key])`.","Use server-level enable/disable APIs with component keys for runtime toggling.","Pin FastMCP <3.0 only as a temporary measure while migrating."],"exampleFix":"// before\ntool.enable()\n// after\nmcp.enable(keys=[tool.key])","handlingStrategy":"try-catch","validationCode":"def can_enable(component) -> bool:\n    import inspect\n    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","typeGuard":null,"tryCatchPattern":"try:\n    tool.enable()\nexcept NotImplementedError:\n    mcp.enable(keys=[tool.key])","preventionTips":["After a major FastMCP upgrade, grep for '.enable()' / '.disable()' on components","Use server.enable/disable(keys=[...]) exclusively in new code","Pin and read the FastMCP 3.0 migration guide"],"tags":["fastmcp","api-removal","migration","version-3"],"backgroundTag":"api-removed-in-major-version","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}