From e48dcfdfa8b4049c55d54812959ddb02ab1928b6 Mon Sep 17 00:00:00 2001 From: Giuseppe Coviello Date: Wed, 9 Jul 2025 17:05:33 -0400 Subject: [PATCH] Avoiding to parse string arguments containing valid JSON if the argument annotation is str, fixes #1112 --- src/mcp/server/fastmcp/utilities/func_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mcp/server/fastmcp/utilities/func_metadata.py b/src/mcp/server/fastmcp/utilities/func_metadata.py index a8f9652de..3c9506fba 100644 --- a/src/mcp/server/fastmcp/utilities/func_metadata.py +++ b/src/mcp/server/fastmcp/utilities/func_metadata.py @@ -130,7 +130,7 @@ def pre_parse_json(self, data: dict[str, Any]) -> dict[str, Any]: for field_name in self.arg_model.model_fields.keys(): if field_name not in data.keys(): continue - if isinstance(data[field_name], str): + if isinstance(data[field_name], str) and self.arg_model.model_fields[field_name].annotation is not str: try: pre_parsed = json.loads(data[field_name]) except json.JSONDecodeError: