Skip to content

NotSupportedException when returning an IEnumerable<ContentBlock> #673

@asklar

Description

@asklar

Repro:

  1. Create an McpServerTool that returns IEnumerable
  2. Observe the following exception:

JsonTypeInfo metadata for type 'System.Collections.Generic.IEnumerable`1[ModelContextProtocol.Protocol.ContentBlock]' was not provided by TypeInfoResolver of type '[ModelContextProtocol.McpJsonUtilities+JsonContext, Microsoft.Extensions.AI.AIJsonUtilities+JsonContext]'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically

Looks like IEnumerable and similar for ContentBlock and derived types is not part of the json serializer context:

internal sealed partial class JsonContext : JsonSerializerContext;

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions