fix: respect resource mime type in responses#170
Merged
Conversation
9dec4ba to
83a3853
Compare
83a3853 to
2c3a283
Compare
The server was ignoring mime types set on resources, defaulting to text/plain for strings and application/octet-stream for bytes. Now properly preserves the specified mime type in both FastMCP and low-level server implementations. Note that this is breaks backwards compatibility as it changes the return values of read_resource() on FastMCP. It is BC compatible on lowlevel since it only extends the callback. Github-Issue: #152 Reported-by: eiseleMichael
Update README examples to show proper handling of the new read_resource() return value that includes mime type information. Github-Issue:#152
89eca5b to
f90cf6a
Compare
jspahrsummers
requested changes
Jan 27, 2025
|
|
||
| - For commits related to a Github issue, add | ||
| ```bash | ||
| git commit --trailer "Github-Issue:#<number>" |
Member
There was a problem hiding this comment.
Suggested change
| git commit --trailer "Github-Issue:#<number>" | |
| git commit --trailer "GitHub-Issue:#<number>" |
Member
|
I think we should make this follow the spec more closely if we're going to break backwards compatibility anyway. |
Introduce ReadResourceContents type to properly handle MIME types in resource responses. Breaking change in FastMCP read_resource() return type. Github-Issue:#152
jspahrsummers
requested changes
Jan 28, 2025
Member
jspahrsummers
left a comment
There was a problem hiding this comment.
What about multiple result values, per my comment?
Member
Author
I thought about it, but honestly, i want to converge to one return value so people dont have to match on the return value. I chose the current appraoch as I want to keep lowlevel fairly BC compatible until v2.0.0 but I am okay changing the higher level FastMCP return value around, since its a bit more faster moving for 1.3.0. |
jspahrsummers
approved these changes
Jan 28, 2025
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
Notable this is a BC breaking change due to the new return values in
read_resource()on FastMCP.Test plan