-
Notifications
You must be signed in to change notification settings - Fork 546
Description
Describe the bug
ElicitRequestParams.RequestSchema has two interfaces without converters, Required (IList) and Properties (IDictionary<string, PrimitiveSchemaDefinition>). Please either specify converters or make them List<> and Dictionary<,> so deserialization in elicitation handler will work.
To Reproduce
Steps to reproduce the behavior:
- Define a schema that is not empty (all tests are just new ElicitRequestParams() btw)
- Send elicitation request to client from server
- System.NotSupportedException: Deserialization of interface or abstract types is not supported. Type 'ModelContextProtocol.Protocol.ElicitRequestParams+PrimitiveSchemaDefinition'. Path: $.requestedSchema.properties.confirm | LineNumber: 0 | BytePositionInLine: 111.
---> System.NotSupportedException: Deserialization of interface or abstract types is not supported. Type 'ModelContextProtocol.Protocol.ElicitRequestParams+PrimitiveSchemaDefinition'.
Expected behavior
The json is deserialized correctly into the ElicitRequestParams instance
Logs
info: ModelContextProtocol.Client.McpClient[570385771]
Main Server method 'elicitation/create' request handler called.
warn: ModelContextProtocol.Client.McpClient[975074943]
Main Server method 'elicitation/create' request handler failed.
System.NotSupportedException: Deserialization of interface or abstract types is not supported. Type 'ModelContextProtocol.Protocol.ElicitRequestParams+PrimitiveSchemaDefinition'. Path: $.requestedSchema.properties.confirm | LineNumber: 0 | BytePositionInLine: 111.
---> System.NotSupportedException: Deserialization of interface or abstract types is not supported. Type 'ModelContextProtocol.Protocol.ElicitRequestParams+PrimitiveSchemaDefinition'.
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ThrowNotSupportedException(ReadStack& state, Utf8JsonReader& reader, Exception innerException)
at System.Text.Json.ThrowHelper.ThrowNotSupportedException_DeserializeNoConstructor(JsonTypeInfo typeInfo, Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
at System.Text.Json.Serialization.JsonDictionaryConverter3.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TDictionary& value) at System.Text.Json.Serialization.Converters.JsonMetadataServicesConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.Converters.JsonMetadataServicesConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.Converters.JsonMetadataServicesConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo1.Deserialize(Utf8JsonReader& reader, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 utf8Json, JsonTypeInfo1 jsonTypeInfo, Nullable1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromNode[TValue](JsonNode node, JsonTypeInfo1 jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[TValue](JsonNode node, JsonTypeInfo1 jsonTypeInfo)
at ModelContextProtocol.RequestHandlers.<>c__DisplayClass0_0`2.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at ModelContextProtocol.McpSession.HandleRequest(JsonRpcRequest request, CancellationToken cancellationToken)
at ModelContextProtocol.McpSession.HandleMessageAsync(JsonRpcMessage message, CancellationToken cancellationToken)
at ModelContextProtocol.McpSession.<>c__DisplayClass23_1.<g__ProcessMessageAsync|0>d.MoveNext()
warn: ModelContextProtocol.Client.McpClient[145193555]
Main Server request failed for method 'tools/call': Request failed (remote): An error occurred. (-32603).
Additional context
N/A