-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix improper conversion of list[Audio | File | Image] helpers #1970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix improper conversion of list[Audio | File | Image] helpers #1970
Conversation
|
this requires a more complex fix, my guess is we might just need to change this: to check for |
Yeah I saw the issue with my first fix, so I changed to only convert fastmcp types (Audio, Image, File). May need to update some tests, I'm not sure if the failing tests is intended behavior or not. |
|
you will need to review the developer guide to ensure your change passes linting, formatting, and type checking and then I would recommend running the tests locally I dont think you need to modify the isinstance check in the list comprehension |
|
I am happy to take over this PR if you'd like otherwise i'll leave you to it, please tag me when you're ready for a review or if you need any help |
That’d be really helpful if you took over. I don’t currently have the bandwidth to finish up the PR so that’d be really helpful, thanks! |
|
@joshrubin-p360 should be ready for you to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the fastmcp type conversion logic to correctly handle lists containing Image, Audio, and File types. The issue was that the condition checking for ContentBlock types was not comprehensive enough, causing mixed content lists to be incorrectly aggregated into a single TextContent block instead of being processed as individual content blocks.
- Updated the type checking condition to include Image, Audio, and File types alongside ContentBlock
- Added test coverage to verify the fix works correctly for lists of convertible types
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/fastmcp/tools/tool.py | Fixed the type checking condition in _convert_to_content to properly handle Image, Audio, and File types |
| tests/tools/test_tool.py | Added test case to verify conversion behavior with lists of content types |
|
@strawgate Thanks for getting this wrapped up! |
|
Let me know if you have any other issues! |
Description
Contributors Checklist
Review Checklist