Environment
- Windows 11 Home (Traditional Chinese)
- Python 3.13
- mempalace 3.3.3
- Claude Code MCP client
Bug
Any non-ASCII Unicode characters in the entry parameter of
mempalace_diary_write (e.g. β
, π, emoji) cause an MCP error -32000.
ASCII-only content works fine.
This affects all CJK Windows users where the default stdin/stdout encoding
is cp950 (Big5) or cp1252, not UTF-8.
Root Cause
The MCP server communicates via JSON-RPC over stdio. On Windows,
sys.stdin.encoding defaults to the system codepage (cp950 for
Traditional Chinese, cp1252 for Western, etc.). When the MCP client sends
UTF-8 encoded JSON containing Unicode characters that don't exist in the
system codepage, sys.stdin.readline() raises a UnicodeDecodeError.
Verified:
# On affected Windows system
import sys
sys.stdin.encoding # 'cp950' β not UTF-8
Fix
Add UTF-8 reconfiguration at the start of main() in mcp_server.py:
def main():
_restore_stdout()
if sys.platform == "win32":
sys.stdin.reconfigure(encoding="utf-8")
sys.stdout.reconfigure(encoding="utf-8")
logger.info("MemPalace MCP Server starting...")
# ... rest of main()
Steps to Reproduce
1. Install mempalace on a Traditional Chinese Windows system
2. Configure as MCP server in Claude Code
3. Call mempalace_diary_write with entry containing β
or any emoji
4. Observe: MCP error -32000 Internal tool error
Workaround
Set environment variable before launching the MCP server:
PYTHONUTF8=1 mempalace-mcp
Environment
Bug
Any non-ASCII Unicode characters in the
entryparameter ofmempalace_diary_write(e.g.β,π, emoji) cause an MCP error -32000.ASCII-only content works fine.
This affects all CJK Windows users where the default stdin/stdout encoding
is cp950 (Big5) or cp1252, not UTF-8.
Root Cause
The MCP server communicates via JSON-RPC over stdio. On Windows,
sys.stdin.encodingdefaults to the system codepage (cp950 forTraditional Chinese, cp1252 for Western, etc.). When the MCP client sends
UTF-8 encoded JSON containing Unicode characters that don't exist in the
system codepage,
sys.stdin.readline()raises aUnicodeDecodeError.Verified: