using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Server;
using ModelContextProtocol.Shared;
namespace ModelContextProtocol;
///
/// Provides an tied to a specific progress token and that will issue
/// progress notifications to the supplied endpoint.
///
internal sealed class TokenProgress(IMcpServer server, ProgressToken progressToken) : IProgress
{
///
public void Report(ProgressNotificationValue value)
{
_ = server.SendMessageAsync(new JsonRpcNotification()
{
Method = NotificationMethods.ProgressNotification,
Params = new ProgressNotification()
{
ProgressToken = progressToken,
Progress = new()
{
Progress = value.Progress,
Total = value.Total,
Message = value.Message,
},
},
}, CancellationToken.None);
}
}