From 244501a6a609db48e8d591ebb2894ea37ab14a33 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Tue, 10 Jun 2025 10:21:06 -0400 Subject: [PATCH] Add enabled property to components --- src/fastmcp/utilities/components.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/fastmcp/utilities/components.py b/src/fastmcp/utilities/components.py index efee70e21..0ad7cca09 100644 --- a/src/fastmcp/utilities/components.py +++ b/src/fastmcp/utilities/components.py @@ -32,6 +32,11 @@ class FastMCPComponent(FastMCPBaseModel): description="Tags for the component.", ) + enabled: bool = Field( + default=True, + description="Whether the component is enabled.", + ) + def __eq__(self, other: object) -> bool: if type(self) is not type(other): return False @@ -40,3 +45,11 @@ class FastMCPComponent(FastMCPBaseModel): def __repr__(self) -> str: return f"{self.__class__.__name__}(name={self.name!r}, description={self.description!r}, tags={self.tags})" + + def enable(self) -> None: + """Enable the component.""" + self.enabled = True + + def disable(self) -> None: + """Disable the component.""" + self.enabled = False