* Propagate CancellationToken request cancellation to remote endpoint * Refactor existing tests to have a shared base class * Add cancellation tests --------- Co-authored-by: Stephen Toub <stoub@microsoft.com>
34 lines
No EOL
1.1 KiB
C#
34 lines
No EOL
1.1 KiB
C#
using ModelContextProtocol.Protocol.Types;
|
|
|
|
namespace EverythingServer;
|
|
|
|
static class ResourceGenerator
|
|
{
|
|
private static readonly List<Resource> _resources = Enumerable.Range(1, 100).Select(i =>
|
|
{
|
|
var uri = $"test://static/resource/{i}";
|
|
if (i % 2 != 0)
|
|
{
|
|
return new Resource
|
|
{
|
|
Uri = uri,
|
|
Name = $"Resource {i}",
|
|
MimeType = "text/plain",
|
|
Description = $"Resource {i}: This is a plaintext resource"
|
|
};
|
|
}
|
|
else
|
|
{
|
|
var buffer = System.Text.Encoding.UTF8.GetBytes($"Resource {i}: This is a base64 blob");
|
|
return new Resource
|
|
{
|
|
Uri = uri,
|
|
Name = $"Resource {i}",
|
|
MimeType = "application/octet-stream",
|
|
Description = Convert.ToBase64String(buffer)
|
|
};
|
|
}
|
|
}).ToList();
|
|
|
|
public static IReadOnlyList<Resource> Resources => _resources;
|
|
} |