Skip to content

fix: do not omitempty ReadOnlyHint in ToolAnnotations#908

Open
pvlbzn wants to merge 1 commit intomodelcontextprotocol:mainfrom
pvlbzn:fix/do-not-omitempty-for-ReadOnlyHint
Open

fix: do not omitempty ReadOnlyHint in ToolAnnotations#908
pvlbzn wants to merge 1 commit intomodelcontextprotocol:mainfrom
pvlbzn:fix/do-not-omitempty-for-ReadOnlyHint

Conversation

@pvlbzn
Copy link
Copy Markdown

@pvlbzn pvlbzn commented Apr 24, 2026

ReadOnlyHint is a bool with omitempty, so the zero value (false) is indistinguishable from unset, and drops out of marshaled JSON.

The current behavior causes an issue with the OpenAI MCP app submission because they require explicit hints.

Consumers that explicitly set ReadOnlyHint: false on write tools lose the field on the wire. Removing omitempty ensures false is always serialized, which matches the MCP spec default.

ReadOnlyHint is a bare bool with omitempty, so the zero value (false)
is indistinguishable from unset and drops out of marshaled JSON.
Consumers that explicitly set ReadOnlyHint: false on write tools lose
the field on the wire. Removing omitempty ensures false is always
serialized, which matches the MCP spec default.

Co-Authored-By: Claude Opus 4.6 <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