Skip to content

feat: Avoid escaping non-ASCII characters when using json.dumps() #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions fastapi_mcp/openapi/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ def convert_openapi_to_mcp_tools(
# If we have an example response, add it to the docs
if example_response:
response_info += "\n\n**Example Response:**\n```json\n"
response_info += json.dumps(example_response, indent=2)
response_info += json.dumps(example_response, indent=2, ensure_ascii=False)
response_info += "\n```"
# Otherwise generate an example from the schema
else:
generated_example = generate_example_from_schema(display_schema)
if generated_example:
response_info += "\n\n**Example Response:**\n```json\n"
response_info += json.dumps(generated_example, indent=2)
response_info += json.dumps(generated_example, indent=2, ensure_ascii=False)
response_info += "\n```"

# Only include full schema information if requested
Expand All @@ -141,15 +141,15 @@ def convert_openapi_to_mcp_tools(
items_schema = display_schema["items"]

response_info += "\n\n**Output Schema:** Array of items with the following structure:\n```json\n"
response_info += json.dumps(items_schema, indent=2)
response_info += json.dumps(items_schema, indent=2, ensure_ascii=False)
response_info += "\n```"
elif "properties" in display_schema:
response_info += "\n\n**Output Schema:**\n```json\n"
response_info += json.dumps(display_schema, indent=2)
response_info += json.dumps(display_schema, indent=2, ensure_ascii=False)
response_info += "\n```"
else:
response_info += "\n\n**Output Schema:**\n```json\n"
response_info += json.dumps(display_schema, indent=2)
response_info += json.dumps(display_schema, indent=2, ensure_ascii=False)
response_info += "\n```"

tool_description += response_info
Expand Down