diff --git a/src/fastmcp/resources/resource.py b/src/fastmcp/resources/resource.py index 55706fd13..9d16e811c 100644 --- a/src/fastmcp/resources/resource.py +++ b/src/fastmcp/resources/resource.py @@ -96,6 +96,9 @@ class Resource(FastMCPComponent, abc.ABC): } return MCPResource(**kwargs | overrides) + def __repr__(self) -> str: + return f"{self.__class__.__name__}(uri={self.uri!r}, name={self.name!r}, description={self.description!r}, tags={self.tags})" + class FunctionResource(Resource): """A resource that defers data loading by wrapping a function. diff --git a/src/fastmcp/utilities/components.py b/src/fastmcp/utilities/components.py index e09374735..efee70e21 100644 --- a/src/fastmcp/utilities/components.py +++ b/src/fastmcp/utilities/components.py @@ -37,3 +37,6 @@ class FastMCPComponent(FastMCPBaseModel): return False assert isinstance(other, type(self)) return self.model_dump() == other.model_dump() + + def __repr__(self) -> str: + return f"{self.__class__.__name__}(name={self.name!r}, description={self.description!r}, tags={self.tags})"