fix: Windows 中文编码修复 - MCP server UTF-8 支持#1291
Conversation
修复 Windows 环境下 MCP server 中文乱码问题。 问题根因: - Windows 默认 stdin/stdout 使用 GBK/CP936 编码 - MCP 协议要求 UTF-8 传输 - 导致中文字符在 JSON-RPC 通信中损坏 修复方案(mempalace/mcp_server.py): 1. 第 1889 行:工具返回结果添加 ensure_ascii=False 2. 第 1949 行:JSON-RPC 响应添加 ensure_ascii=False 3. main() 函数:Windows 平台强制包装 stdin/stdout 为 UTF-8 跨平台兼容: - 使用 sys.platform == 'win32' 检测 - Linux/macOS 默认 UTF-8,无需包装 - ensure_ascii=False 对所有平台都有益 测试结果: - ✅ Windows: 中文读写完全正常 - ✅ Linux/macOS: 不受影响,保持原有 UTF-8 行为 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Thanks for this fix. The stdio reconfigure portion of this PR overlaps with #1259, which addresses the same Windows encoding problem using That said, the Would you be willing to open a separate PR with just the |
- Add ChromaDB connection warmup - Add HNSW index health check - Add Knowledge Graph loading - Fix datetime import in _log() Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Thanks for the clear and helpful feedback! I've split the changes as you suggested into one separate PR:
I'll close this original PR in favor of the split one, to keep things clean and decoupled as you recommended. |
修复 Windows 环境下 MCP server 中文乱码问题。
问题根因:
修复方案(mempalace/mcp_server.py):
跨平台兼容:
测试结果:
What does this PR do?
How to test
Checklist
python -m pytest tests/ -v)ruff check .)