Update content according to latest spec (#513)

* Update content according to latest spec

* Add Title to a bunch of types

* Add _meta to lots of types

* Address feedback, more cleanup, fix NAOT test failure
This commit is contained in:
Stephen Toub 2025-06-16 19:39:41 -04:00 • committed by GitHub
commit 2bcff315f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,15 +44,11 @@ public class McpClientExtensionsTests : ClientServerTestBase
new SamplingMessage
{
Role = Role.User,
Content = new Content { Type = "text", Text = "Hello" }
Content = new TextContentBlock { Text = "Hello" }
}
],
Temperature = temperature,
MaxTokens = maxTokens,
Meta = new RequestParamsMetadata
{
ProgressToken = new ProgressToken(),
}
};
var cancellationToken = CancellationToken.None;
@ -80,7 +76,7 @@ public class McpClientExtensionsTests : ClientServerTestBase
// Assert
Assert.NotNull(result);
Assert.Equal("Hello, World!", result.Content.Text);
Assert.Equal("Hello, World!", (result.Content as TextContentBlock)?.Text);
Assert.Equal("test-model", result.Model);
Assert.Equal(Role.Assistant, result.Role);
Assert.Equal("endTurn", result.StopReason);
@ -98,9 +94,8 @@ public class McpClientExtensionsTests : ClientServerTestBase
new SamplingMessage
{
Role = Role.User,
Content = new Content
Content = new ImageContentBlock
{
Type = "image",
MimeType = "image/png",
Data = Convert.ToBase64String(new byte[] { 1, 2, 3 })
}
@ -135,7 +130,7 @@ public class McpClientExtensionsTests : ClientServerTestBase
// Assert
Assert.NotNull(result);
Assert.Equal(expectedData, result.Content.Data);
Assert.Equal(expectedData, (result.Content as ImageContentBlock)?.Data);
Assert.Equal("test-model", result.Model);
Assert.Equal(Role.Assistant, result.Role);
Assert.Equal("endTurn", result.StopReason);
@ -162,11 +157,7 @@ public class McpClientExtensionsTests : ClientServerTestBase
new SamplingMessage
{
Role = Role.User,
Content = new Content
{
Type = "resource",
Resource = resource
},
Content = new EmbeddedResourceBlock { Resource = resource },
}
],
MaxTokens = 100
@ -284,7 +275,7 @@ public class McpClientExtensionsTests : ClientServerTestBase
JsonSerializerOptions emptyOptions = new() { TypeInfoResolver = JsonTypeInfoResolver.Combine() };
await using IMcpClient client = await CreateMcpClientForServer();
await Assert.ThrowsAsync<NotSupportedException>(async () => await client.SendRequestAsync<CallToolRequestParams, CallToolResponse>("Method4", new() { Name = "tool" }, emptyOptions, cancellationToken: TestContext.Current.CancellationToken));
await Assert.ThrowsAsync<NotSupportedException>(async () => await client.SendRequestAsync<CallToolRequestParams, CallToolResult>("Method4", new() { Name = "tool" }, emptyOptions, cancellationToken: TestContext.Current.CancellationToken));
}
[Fact]