diff --git a/src/fastmcp/utilities/openapi.py b/src/fastmcp/utilities/openapi.py index 044d58aa3..886456ca7 100644 --- a/src/fastmcp/utilities/openapi.py +++ b/src/fastmcp/utilities/openapi.py @@ -82,13 +82,9 @@ def format_array_parameter( return values else: # For path parameters, fallback to string representation without Python syntax - str_value = ( - str(values) - .replace("[", "") - .replace("]", "") - .replace("'", "") - .replace('"', "") - ) + # Use str.translate() for efficient character removal + translation_table = str.maketrans("", "", "[]'\"") + str_value = str(values).translate(translation_table) return str_value