Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
2a88273
1
Parent(s): 1430816
Add enabled property to components
Browse files
src/fastmcp/utilities/components.py
CHANGED
|
@@ -32,6 +32,11 @@ class FastMCPComponent(FastMCPBaseModel):
|
|
| 32 |
description="Tags for the component.",
|
| 33 |
)
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
def __eq__(self, other: object) -> bool:
|
| 36 |
if type(self) is not type(other):
|
| 37 |
return False
|
|
@@ -40,3 +45,11 @@ class FastMCPComponent(FastMCPBaseModel):
|
|
| 40 |
|
| 41 |
def __repr__(self) -> str:
|
| 42 |
return f"{self.__class__.__name__}(name={self.name!r}, description={self.description!r}, tags={self.tags})"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
description="Tags for the component.",
|
| 33 |
)
|
| 34 |
|
| 35 |
+
enabled: bool = Field(
|
| 36 |
+
default=True,
|
| 37 |
+
description="Whether the component is enabled.",
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
def __eq__(self, other: object) -> bool:
|
| 41 |
if type(self) is not type(other):
|
| 42 |
return False
|
|
|
|
| 45 |
|
| 46 |
def __repr__(self) -> str:
|
| 47 |
return f"{self.__class__.__name__}(name={self.name!r}, description={self.description!r}, tags={self.tags})"
|
| 48 |
+
|
| 49 |
+
def enable(self) -> None:
|
| 50 |
+
"""Enable the component."""
|
| 51 |
+
self.enabled = True
|
| 52 |
+
|
| 53 |
+
def disable(self) -> None:
|
| 54 |
+
"""Disable the component."""
|
| 55 |
+
self.enabled = False
|