diff --git a/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs b/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs index 664ede5a..cb88e637 100644 --- a/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs +++ b/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs @@ -257,10 +257,13 @@ public override async ValueTask InvokeAsync( Content = [], StructuredContent = structuredContent, }, - + string text => new() { - Content = [new TextContentBlock { Text = text }], + // If there is structuredOutput we must stringify it, as the MCP specification requires Content to be for backwards compatibility + // but otherwise not differ + Content = [new TextContentBlock { Text = structuredContent == null ? text : + JsonSerializer.Serialize(structuredContent, AIFunction.JsonSerializerOptions.GetTypeInfo(typeof(object)))}], StructuredContent = structuredContent, },