From 5914a09170e5ba257fc6ecacf51a7690d25416a1 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Tue, 10 Jun 2025 09:45:06 -0400 Subject: [PATCH 1/2] Remove extra equal dunders --- src/fastmcp/resources/resource.py | 6 ------ src/fastmcp/resources/template.py | 6 ------ src/fastmcp/tools/tool.py | 6 ------ 3 files changed, 18 deletions(-) diff --git a/src/fastmcp/resources/resource.py b/src/fastmcp/resources/resource.py index ad25ec10d..55706fd13 100644 --- a/src/fastmcp/resources/resource.py +++ b/src/fastmcp/resources/resource.py @@ -86,12 +86,6 @@ class Resource(FastMCPComponent, abc.ABC): """Read the resource content.""" pass - def __eq__(self, other: object) -> bool: - if type(self) is not type(other): - return False - assert isinstance(other, type(self)) - return self.model_dump() == other.model_dump() - def to_mcp_resource(self, **overrides: Any) -> MCPResource: """Convert the resource to an MCPResource.""" kwargs = { diff --git a/src/fastmcp/resources/template.py b/src/fastmcp/resources/template.py index b0da1d74a..c8faaa188 100644 --- a/src/fastmcp/resources/template.py +++ b/src/fastmcp/resources/template.py @@ -115,12 +115,6 @@ class ResourceTemplate(FastMCPComponent): tags=self.tags, ) - def __eq__(self, other: object) -> bool: - if type(self) is not type(other): - return False - assert isinstance(other, type(self)) - return self.model_dump() == other.model_dump() - def to_mcp_template(self, **overrides: Any) -> MCPResourceTemplate: """Convert the resource template to an MCPResourceTemplate.""" kwargs = { diff --git a/src/fastmcp/tools/tool.py b/src/fastmcp/tools/tool.py index 0859cac99..2b334f617 100644 --- a/src/fastmcp/tools/tool.py +++ b/src/fastmcp/tools/tool.py @@ -74,12 +74,6 @@ class Tool(FastMCPComponent, ABC): serializer=serializer, ) - def __eq__(self, other: object) -> bool: - if type(self) is not type(other): - return False - assert isinstance(other, type(self)) - return self.model_dump() == other.model_dump() - @abstractmethod async def run( self, arguments: dict[str, Any] From 66ae3fbfea9acb3dd076dc1807a4af7bc0f1fa93 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Tue, 10 Jun 2025 09:48:04 -0400 Subject: [PATCH 2/2] add repr --- src/fastmcp/resources/resource.py | 3 +++ src/fastmcp/utilities/components.py | 3 +++ 2 files changed, 6 insertions(+) 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})"