Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Add enabled property to components

Jeremiah Lowin244501a6a609
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