Skip to content

Commit 4b81d6e

Browse files
authored
fix: preserve non-ASCII characters in JSON output
Add ensure_ascii=False parameter to json.dumps() when converting results to JSON strings in _convert_to_content function. This prevents Unicode characters (like Chinese) from being escaped as \uXXXX sequences, making the output more readable and user-friendly for multilingual content.
1 parent b4c7db6 commit 4b81d6e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/mcp/server/fastmcp/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def _convert_to_content(
552552

553553
if not isinstance(result, str):
554554
try:
555-
result = json.dumps(pydantic_core.to_jsonable_python(result))
555+
result = json.dumps(pydantic_core.to_jsonable_python(result), ensure_ascii=False)
556556
except Exception:
557557
result = str(result)
558558

0 commit comments

Comments
 (0)