fix(mcpserver): serialize empty list and tuple returns into TextContent - #3339
fix(mcpserver): serialize empty list and tuple returns into TextContent#3339Maazkorejo wants to merge 1 commit into
Conversation
|
Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because you aren't currently assigned to #3307. If a maintainer would like this change as a PR from you, they'll assign you to #3307 and this PR will reopen automatically — there's nothing more you need to do. (If you opened the issue, this PR already shows up on its timeline.) There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten. Maintainers: reopening this PR, removing the |
Description
Fixes #3307
When a
@mcp.tool()function returns an empty list[]or tuple(),_convert_to_contentpreviously collapsed the return value into an empty list of content blocks (content: []). This caused downstream clients (such as Claude Desktop, LangGraph, and IDE integrations) to treat valid empty results as errored executions due to zero content blocks.Changes Made
_convert_to_contentinsrc/mcp/server/mcpserver/utilities/func_metadata.pyto return[TextContent(type="text", text="[]")]for empty lists (and"()"for empty tuples).tests/server/mcpserver/test_func_metadata.py.tests/interaction/mcpserver/test_tools.py.Checklist