Repository navigation
Read CLI-scanned MCP config files as UTF-8 explicitly - #4690
Merged
Merged
Conversation
Fixes UnicodeDecodeError in `fastmcp discover` on Windows when the system locale isn't UTF-8 (e.g. cp949) and a scanned config file (Claude Desktop, Claude Code, project mcp.json, Cursor, Gemini, Goose) contains a non-ASCII byte.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fastmcp discoverreads MCP config files (Claude Desktop, Claude Code, projectmcp.json, Cursor, Gemini, Goose) withPath.read_text(), which falls back to the OS's preferred encoding when none is given. On Windows with a non-UTF-8 locale (cp949, cp932, cp936), any non-ASCII byte in a config file — like an em dash written by another tool — raises an unhandledUnicodeDecodeErrorand crashes the command.These files are always written as UTF-8 by the tools that produce them, so read them as UTF-8 explicitly rather than trusting the platform locale. Same pattern as the fixes in #3579, #4084, #4164, and #4532.
Closes #4689