Skip to content

Comments

Fix: Ensure correct character encoding for tool outputs#74

Open
aac6fef wants to merge 1 commit intoMarkusPfundstein:mainfrom
aac6fef:main
Open

Fix: Ensure correct character encoding for tool outputs#74
aac6fef wants to merge 1 commit intoMarkusPfundstein:mainfrom
aac6fef:main

Conversation

@aac6fef
Copy link

@aac6fef aac6fef commented Aug 13, 2025

#73
This PR addresses an issue where non-ASCII characters in tool outputs were being incorrectly encoded, resulting in garbled text (e.g., \u4f60\u597d\u4e16\u754c).

The following changes have been made:

  1. Updated json.dumps calls: In src/mcp_obsidian/tools.py, all instances of json.dumps have been updated to include the ensure_ascii=False parameter. This ensures that multibyte characters are rendered correctly in the output.
  2. Corrected GetFileContentsToolHandler: Removed an unnecessary json.dumps call that was wrapping the raw text output. The handler now returns the file content directly, as expected.

These changes ensure proper handling of international characters across all relevant tools, improving the usability and correctness of the integration.

ernestkoe added a commit to ernestkoe/mcp-obsidian-ek that referenced this pull request Dec 29, 2025
- Add Windows UTF-8 STDIO encoding fix (PR MarkusPfundstein#75)
- Add ensure_ascii=False to json.dumps for proper Unicode (PR MarkusPfundstein#74)
- Add Dataview query tool for arbitrary DQL queries (PR MarkusPfundstein#53)

Skipped (already fixed by PR MarkusPfundstein#77):
- PR MarkusPfundstein#87: dirpath trailing slashes
- PR MarkusPfundstein#67: list_files_in_dir slash

Skipped (not needed):
- PR MarkusPfundstein#89: env var defaults (our approach works)
- PR MarkusPfundstein#69: too large, needs review

70 tests passing, 26 tools total.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ernestkoe
Copy link

Applied to my maintained fork at https://github.com/ernestkoe/mcp-obsidian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants