Skip to content

Remove special-casing of string enumerables in McpServerTool #699

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

Conversation

stephentoub
Copy link
Contributor

We special-case string enumerables, translating them to an array of text content blocks, but other enumerables just get serialized, and there's a reasonable expectation that returning a string[] would produce a JSON array of strings. Just delete the special-casing.

Fixes #698

cc: @AArnott

We special-case string enumerables, translating them to an array of text content blocks, but other enumerables just get serialized, and there's a reasonable expectation that returning a string[] would produce a JSON array of strings. Just delete the special-casing.
@PederHP
Copy link
Collaborator

PederHP commented Aug 12, 2025

Yeah, agree. One downside is that it's no longer possible to return multiple text blocks by using string array as the return type. And it's a valid signature for tools (can make sense in some cases, as it's different schema wise at the LLM api level). I can't recall if it's possible to return this via array of text AIContent. If so, nothing lost.

@stephentoub
Copy link
Contributor Author

I can't recall if it's possible to return this via array of text AIContent. If so, nothing lost.

You can return an AIContent[], a TextContentBlock[], or even a CallToolResult.

@stephentoub stephentoub merged commit 70960e1 into modelcontextprotocol:main Aug 13, 2025
19 of 28 checks passed
@stephentoub stephentoub deleted the stringarrayresult branch August 13, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MCP tools that return string[] get different schema from SomethingElse[]
5 participants