Skip to content

fix(publisher): accept UTF-8 BOM in server.json - #1528

Open
beeswaxpat wants to merge 1 commit into
modelcontextprotocol:mainfrom
beeswaxpat:fix-bom-server-json
Open

fix(publisher): accept UTF-8 BOM in server.json#1528
beeswaxpat wants to merge 1 commit into
modelcontextprotocol:mainfrom
beeswaxpat:fix-bom-server-json

Conversation

@beeswaxpat

Copy link
Copy Markdown

On Windows, PowerShell 5.1's Out-File -Encoding utf8 (and several editors) write UTF-8 files with a leading byte order mark. Go's encoding/json does not skip the BOM, so mcp-publisher publish and mcp-publisher validate fail on such server.json files with the cryptic error invalid character 'ï' looking for beginning of value. RFC 8259 section 8.1 says implementations may ignore a leading BOM, and we hit this in practice publishing a server from a Windows machine.

This change strips a leading UTF-8 BOM (EF BB BF) from server.json bytes right after the file is read in both the publish and validate commands, using a small shared helper next to the existing UTF-8 validation in unicode.go. Both downstream request paths receive the cleaned bytes, so behavior is otherwise unchanged. Adds two tests that run a BOM-prefixed server.json through the full publish and validate paths.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant