Skip to content

【bug】json.dumps(response) does not set ensure_ascii=False #359

@janzwang666555-lab

Description

@janzwang666555-lab

Description

File: mempalace/mcp_server.py, lines 679 and 683

Problem:
json.dumps(response) is called without ensure_ascii=False.

Trigger:
Any string field (content, wing, room, etc.) contains Chinese (or other non-ASCII) characters.

Error Chain:

  • WorkBuddy sends a JSON-RPC request containing Chinese characters.
  • The MCP protocol stack parses the JSON, decoding Chinese into Python strings with lone surrogate characters (e.g. \udca3).
  • The string is passed as-is to the handler → returns a result dict.
  • json.dumps(result) fails during serialization because UTF-8 cannot encode the surrogate characters → error is raised.

Expected Behavior:
The server should correctly return JSON containing Chinese characters without crashing.

Suggested Fix

Add ensure_ascii=False when calling json.dumps():

# Before
json.dumps(response)

# After
json.dumps(response, ensure_ascii=False)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/i18nMultilingual, Unicode, non-English embeddingsarea/mcpMCP server and toolsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions