Add EverythingServer sample (#151)

This commit is contained in:
Aaron Powell 2025-04-05 05:48:53 +11:00 • committed by GitHub
commit 01410df5ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,37 @@
using ModelContextProtocol.Protocol.Types;
using System;
using System.Collections.Generic;
using System.Linq;
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;
}