fix: allow MIME type parameters in resource validation (RFC 2045)#1755
Merged
maxisbey merged 2 commits intomodelcontextprotocol:mainfrom Dec 9, 2025
Merged
Conversation
The MIME type validation regex was too restrictive and rejected valid RFC 2045 MIME types with parameters like `text/html;profile=mcp-app`. This is needed for MCP-UI widgets that use parameterized MIME types. The regex now supports: - Basic types: text/plain, application/json - With parameters: text/html;profile=mcp-app, application/json; charset=utf-8 - Multiple parameters: text/plain; charset=utf-8; format=fixed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Github-Issue: modelcontextprotocol#1754
maxisbey
approved these changes
Dec 9, 2025
Contributor
maxisbey
left a comment
There was a problem hiding this comment.
Thanks for fixing this! The regex change correctly handles the common parameter cases needed for MCP Apps SDK compatibility.
One note: the regex is still more restrictive than RFC 2045 (doesn't support quoted string values like charset="utf-8"), but this covers the practical use cases. Opened #1756 to track aligning with the TypeScript SDK approach.
The resource functions are only used for metadata validation, not actually called in these tests.
Contributor
|
This PR is included in version v1.23.3 |
9 tasks
9 tasks
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.
Summary
text/html;profile=mcp-appwere rejectedFixes #1754
Details
The MIME type validation regex in FastMCP's
Resourceclass was too restrictive:Now supports:
text/plain,application/jsontext/html;profile=mcp-app,application/json; charset=utf-8text/plain; charset=utf-8; format=fixedTest plan
tests/issues/test_1754_mime_type_parameters.pywith 4 test cases🤖 Generated with Claude Code