Skip to content

fix(mcpserver): serialize empty list and tuple returns into TextContent - #3339

Closed
Maazkorejo wants to merge 1 commit into
modelcontextprotocol:mainfrom
Maazkorejo:fix/fastmcp-empty-list-content
Closed

fix(mcpserver): serialize empty list and tuple returns into TextContent#3339
Maazkorejo wants to merge 1 commit into
modelcontextprotocol:mainfrom
Maazkorejo:fix/fastmcp-empty-list-content

Conversation

@Maazkorejo

Copy link
Copy Markdown

Description

Fixes #3307

When a @mcp.tool() function returns an empty list [] or tuple (), _convert_to_content previously 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

  • Updated _convert_to_content in src/mcp/server/mcpserver/utilities/func_metadata.py to return [TextContent(type="text", text="[]")] for empty lists (and "()" for empty tuples).
  • Added unit test in tests/server/mcpserver/test_func_metadata.py.
  • Added end-to-end client/server interaction test in tests/interaction/mcpserver/test_tools.py.

Checklist

@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Aug 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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 missing-issue-link label, or adding bypass-issue-check bypasses the check.

@github-actions github-actions Bot closed this Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamable HTTP clean EOF reconnects can exceed the request retry budget

1 participant