From 337cd41f5f4d0be8d4771ec2c6846fb17573bc63 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Mon, 28 Jul 2025 18:11:32 -0400 Subject: [PATCH] Sort tags for deterministic output --- src/fastmcp/utilities/components.py | 2 +- tests/server/openapi/test_basic_functionality.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fastmcp/utilities/components.py b/src/fastmcp/utilities/components.py index 715084a8b..f2955c6b0 100644 --- a/src/fastmcp/utilities/components.py +++ b/src/fastmcp/utilities/components.py @@ -63,7 +63,7 @@ class FastMCPComponent(FastMCPBaseModel): def get_meta(self) -> dict[str, Any]: """Get the meta information about the component.""" if self.tags: - return {"tags": list(self.tags)} | self.meta + return {"tags": sorted(self.tags)} | self.meta else: return self.meta diff --git a/tests/server/openapi/test_basic_functionality.py b/tests/server/openapi/test_basic_functionality.py index 29e67360f..014531b87 100644 --- a/tests/server/openapi/test_basic_functionality.py +++ b/tests/server/openapi/test_basic_functionality.py @@ -97,7 +97,7 @@ class TestTools: assert tools[0].model_dump() == dict( name="create_user_users_post", - meta={"tags": ["users", "create"]}, + meta=dict(tags=["create", "users"]), title=None, annotations=None, description=IsStr(regex=r"^Create a new user\..*$", regex_flags=re.DOTALL), @@ -122,7 +122,7 @@ class TestTools: ) assert tools[1].model_dump() == dict( name="update_user_name_users", - meta={"tags": ["users", "update"]}, + meta=dict(tags=["update", "users"]), title=None, annotations=None, description=IsStr(