Remove special-casing of string enumerables in McpServerTool (#699)

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.
This commit is contained in:
Stephen Toub 2025-08-13 13:05:42 -04:00 • committed by GitHub
commit 70960e1f1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -254,8 +254,7 @@ public partial class McpServerBuilderExtensionsToolsTests : ClientServerTestBase
Assert.NotNull(result.Content);
Assert.NotEmpty(result.Content);
Assert.Equal("hello Peter", (result.Content[0] as TextContentBlock)?.Text);
Assert.Equal("hello2 Peter", (result.Content[1] as TextContentBlock)?.Text);
Assert.Equal("""["hello Peter","hello2 Peter"]""", (result.Content[0] as TextContentBlock)?.Text);
result = await client.CallToolAsync(
"SecondCustomTool",