Skip to content

Comments

fix: allow empty content in CallToolResult#681

Merged
jokemanfire merged 1 commit intomodelcontextprotocol:mainfrom
anishathalye:allow-empty-content
Feb 24, 2026
Merged

fix: allow empty content in CallToolResult#681
jokemanfire merged 1 commit intomodelcontextprotocol:mainfrom
anishathalye:allow-empty-content

Conversation

@anishathalye
Copy link
Contributor

Per the MCP spec [1] and the TypeScript schema [2], CallToolResult.content is typed as ContentBlock[], so it is a required array with no minimum length constraint.

MCP server libraries use such a representation in practice: for example, FastMCP returns responses with no structuredContent and an empty content array when tools return None.


Motivation and Context

See above.

How Has This Been Tested?

Updated unit tests, included in this PR.

Breaking Changes

This is more permissive, so I don't think this should break anything.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

N/A.

@anishathalye anishathalye requested a review from a team as a code owner February 23, 2026 23:15
@github-actions github-actions bot added T-test Testing related changes T-core Core library changes labels Feb 23, 2026
jokemanfire
jokemanfire previously approved these changes Feb 24, 2026
Copy link
Member

@jokemanfire jokemanfire left a comment

Choose a reason for hiding this comment

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

In spec , the office's description is Tool results may contain [structured](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#structured-content) or unstructured content.
Looks like the content could be empty.

@jokemanfire
Copy link
Member

fix the ci please.

Per the MCP spec [1] and the TypeScript schema [2],
`CallToolResult.content` is typed as `ContentBlock[]`, so it is a
required array with no minimum length constraint.

MCP server libraries use such a representation in practice: for example,
FastMCP returns responses with no `structuredContent` and an empty
`content` array when tools return `None`.

[1]: https://modelcontextprotocol.io/specification/2025-11-25/server/tools
[2]: https://github.com/modelcontextprotocol/specification/blob/main/schema/2025-11-25/schema.ts
@anishathalye anishathalye changed the title Allow empty content in CallToolResult fix: allow empty content in CallToolResult Feb 24, 2026
@anishathalye
Copy link
Contributor Author

CI fixed. The one in this repo is awaiting maintainer approval: https://github.com/modelcontextprotocol/rust-sdk/actions/runs/22334296705

$ npx commitlint --from 0854700 --to 9847bde --verbose
⧗   input: fix: allow empty content in CallToolResult

Per the MCP spec [1] and the TypeScript schema [2],
`CallToolResult.content` is typed as `ContentBlock[]`, so it is a
required array with no minimum length constraint.

MCP server libraries use such a representation in practice: for example,
FastMCP returns responses with no `structuredContent` and an empty
`content` array when tools return `None`.

[1]: https://modelcontextprotocol.io/specification/2025-11-25/server/tools
[2]: https://github.com/modelcontextprotocol/specification/blob/main/schema/2025-11-25/schema.ts
✔   found 0 problems, 0 warnings

$ cargo +nightly fmt --all -- --check; echo $?
0

@jokemanfire jokemanfire merged commit 98eef44 into modelcontextprotocol:main Feb 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants