* Remove `McpEndpoint` & `IMcpClient` * Revise naming, add abstract classes * Fix missing renames * Move extension methods to instance methods * Add back old API, but obsoleted * Add back obsoleted factory classes * Move deprecation attributes * `SseClientTransport` -> `HttpClientTransport` * Update src/ModelContextProtocol.Core/Server/AugmentedServiceProvider.cs Co-authored-by: Stephen Halter <halter73@gmail.com> * PR feedback * PR feedback * Add back dispose lock * Fix docs projects * PR feedback * Undo `docs/*.md` changes --------- Co-authored-by: Stephen Halter <halter73@gmail.com>
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using ModelContextProtocol;
|
|
using ModelContextProtocol.Protocol;
|
|
using ModelContextProtocol.Server;
|
|
using System.ComponentModel;
|
|
|
|
namespace EverythingServer.Tools;
|
|
|
|
[McpServerToolType]
|
|
public class LongRunningTool
|
|
{
|
|
[McpServerTool(Name = "longRunningOperation"), Description("Demonstrates a long running operation with progress updates")]
|
|
public static async Task<string> LongRunningOperation(
|
|
McpServer server,
|
|
RequestContext<CallToolRequestParams> context,
|
|
int duration = 10,
|
|
int steps = 5)
|
|
{
|
|
var progressToken = context.Params?.ProgressToken;
|
|
var stepDuration = duration / steps;
|
|
|
|
for (int i = 1; i <= steps + 1; i++)
|
|
{
|
|
await Task.Delay(stepDuration * 1000);
|
|
|
|
if (progressToken is not null)
|
|
{
|
|
await server.SendNotificationAsync("notifications/progress", new
|
|
{
|
|
Progress = i,
|
|
Total = steps,
|
|
progressToken
|
|
});
|
|
}
|
|
}
|
|
|
|
return $"Long running operation completed. Duration: {duration} seconds. Steps: {steps}.";
|
|
}
|
|
}
|