Skip to content

Fix tool result serialization when the tool returns a list #379

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

Merged
merged 1 commit into from
May 9, 2025

Conversation

strawgate
Copy link
Contributor

@strawgate strawgate commented May 9, 2025

Fixes #378

@Copilot Copilot AI review requested due to automatic review settings May 9, 2025 01:04
Copy link
Contributor

@Copilot Copilot AI left a 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 tool result serialization when a tool returns a list by ensuring that a custom serializer is correctly propagated.

  • Added a test (test_call_tool_with_list_result_custom_serializer) that verifies a custom serializer is applied to list results.
  • Updated _convert_to_content to pass the serializer parameter during recursive conversion of list items.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/tools/test_tool_manager.py Added a new test to ensure custom serialization logic for lists.
src/fastmcp/tools/tool.py Propagated the serializer in recursive calls to _convert_to_content.

@strawgate strawgate force-pushed the fix-tool-serializer branch from 27be765 to a12edd7 Compare May 9, 2025 01:33
Copy link
Owner

@jlowin jlowin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@jlowin jlowin added the bug Something isn't working label May 9, 2025
@jlowin jlowin merged commit 748d6bd into jlowin:main May 9, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tool serializer is not passed during recursive convert content calls
2 participants