Make LoggingMessageNotificationParams.Data required per MCP spec (#1353)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This commit is contained in:
parent
9b5d0fe80a
commit
571e4dc127
3 changed files with 8 additions and 9 deletions
|
|
@ -45,8 +45,9 @@ public sealed class LoggingMessageNotificationParams : NotificationParams
|
||||||
public string? Logger { get; set; }
|
public string? Logger { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the data to be logged, such as a string message.
|
/// Gets or sets the data to be logged, such as a string message or an object.
|
||||||
|
/// Any JSON serializable type is allowed here.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("data")]
|
[JsonPropertyName("data")]
|
||||||
public JsonElement? Data { get; set; }
|
public required JsonElement Data { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -539,11 +539,9 @@ public class McpClientTests : ClientServerTestBase
|
||||||
{
|
{
|
||||||
var m = await channel.Reader.ReadAsync(TestContext.Current.CancellationToken);
|
var m = await channel.Reader.ReadAsync(TestContext.Current.CancellationToken);
|
||||||
Assert.NotNull(m);
|
Assert.NotNull(m);
|
||||||
Assert.NotNull(m.Data);
|
|
||||||
|
|
||||||
Assert.Equal("TestLogger", m.Logger);
|
Assert.Equal("TestLogger", m.Logger);
|
||||||
|
|
||||||
string? s = JsonSerializer.Deserialize<string>(m.Data.Value, McpJsonUtilities.DefaultOptions);
|
string? s = JsonSerializer.Deserialize<string>(m.Data, McpJsonUtilities.DefaultOptions);
|
||||||
Assert.NotNull(s);
|
Assert.NotNull(s);
|
||||||
|
|
||||||
if (s.Contains("Information"))
|
if (s.Contains("Information"))
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@ public static class LoggingMessageNotificationParamsTests
|
||||||
Assert.NotNull(deserialized);
|
Assert.NotNull(deserialized);
|
||||||
Assert.Equal(LoggingLevel.Warning, deserialized.Level);
|
Assert.Equal(LoggingLevel.Warning, deserialized.Level);
|
||||||
Assert.Equal("MyApp.Services", deserialized.Logger);
|
Assert.Equal("MyApp.Services", deserialized.Logger);
|
||||||
Assert.NotNull(deserialized.Data);
|
Assert.Equal("Something went wrong", deserialized.Data.GetString());
|
||||||
Assert.Equal("Something went wrong", deserialized.Data.Value.GetString());
|
|
||||||
Assert.NotNull(deserialized.Meta);
|
Assert.NotNull(deserialized.Meta);
|
||||||
Assert.Equal("value", (string)deserialized.Meta["key"]!);
|
Assert.Equal("value", (string)deserialized.Meta["key"]!);
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +33,8 @@ public static class LoggingMessageNotificationParamsTests
|
||||||
{
|
{
|
||||||
var original = new LoggingMessageNotificationParams
|
var original = new LoggingMessageNotificationParams
|
||||||
{
|
{
|
||||||
Level = LoggingLevel.Error
|
Level = LoggingLevel.Error,
|
||||||
|
Data = JsonDocument.Parse("\"error occurred\"").RootElement.Clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
string json = JsonSerializer.Serialize(original, McpJsonUtilities.DefaultOptions);
|
string json = JsonSerializer.Serialize(original, McpJsonUtilities.DefaultOptions);
|
||||||
|
|
@ -43,7 +43,7 @@ public static class LoggingMessageNotificationParamsTests
|
||||||
Assert.NotNull(deserialized);
|
Assert.NotNull(deserialized);
|
||||||
Assert.Equal(LoggingLevel.Error, deserialized.Level);
|
Assert.Equal(LoggingLevel.Error, deserialized.Level);
|
||||||
Assert.Null(deserialized.Logger);
|
Assert.Null(deserialized.Logger);
|
||||||
Assert.Null(deserialized.Data);
|
Assert.Equal("error occurred", deserialized.Data.GetString());
|
||||||
Assert.Null(deserialized.Meta);
|
Assert.Null(deserialized.Meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue