Skip to content

Replace FileResource.is_binary with an encoding field - #3171

Merged
maxisbey merged 3 commits into
mainfrom
file-resource-encoding
Jul 25, 2026
Merged

Replace FileResource.is_binary with an encoding field#3171
maxisbey merged 3 commits into
mainfrom
file-resource-encoding

Shrink the textual mime set and default text to utf-8-sig

769fd84
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 25, 2026 in 13m 27s

Code review found 2 potential issues

Found 2 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/mcp/server/mcpserver/resources/types.py:174-183 validate_known_encoding accepts non-text codecs that then fail on first read

Annotations

Check warning on line 183 in src/mcp/server/mcpserver/resources/types.py

See this annotation in the file changed.

@claude claude / Claude Code Review

validate_known_encoding accepts non-text codecs that then fail on first read

The new `validate_known_encoding` validator accepts non-text transform codecs like `'base64'`, `'hex'`, `'zlib'`, and `'rot13'` — `codecs.lookup()` succeeds for them, but `Path.read_text()` then rejects them with `LookupError` on the first read, which is exactly the deferred failure the validator (and migration.md's "fails at construction rather than on the first read" promise) was added to prevent. Also rejecting codecs where `not codecs.lookup(encoding)._is_text_encoding` — mirroring what `ope