using ModelContextProtocol;
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using System.ComponentModel;
namespace LongRunningTasks.Tools;
///
/// Demonstrates creating and returning tasks via .
///
[McpServerToolType]
public class TaskTools(IMcpTaskStore taskStore)
{
///
/// Submits a job to the task store and returns a task handle for polling.
///
[McpServerTool]
[Description("Submits a job and returns a task that can be polled for completion.")]
public Task SubmitJob(
[Description("A label for the job")] string jobName,
RequestContext context,
CancellationToken cancellationToken)
{
return taskStore.CreateTaskAsync(
new McpTaskMetadata { TimeToLive = TimeSpan.FromMinutes(10) },
context.JsonRpcRequest.Id!,
context.JsonRpcRequest,
context.Server.SessionId,
cancellationToken);
}
}