How to implement Progress Reporting in C# SDK #571
Unanswered
YashasAnand asked this question in Q&A
Replies: 1 comment
-
Augment your tool to accept a parameter of type e.g. modifying your example: [McpServerTool, Description("Retrieves the status counts of all jobs for a specific device.")] public async Task<JobStatusCountsData?> GetJobStatusCountsAsync( [Description("ID to fetch the job status counts.")] string Id, + IProgress<ProgressNotificationValue> progress, CancellationToken cancellationToken = default) { + progress.Report(new() { Progress = 0.0, Message = "Starting..." }; ... } |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission Checklist
Question Category
Your Question
I am trying to implement a C# Server SDK with a long running task. How do I implement progress reporting with C# sdk.
[McpServerTool, Description("Retrieves the status counts of all jobs for a specific device.")]
public async Task<JobStatusCountsData?> GetJobStatusCountsAsync(
[Description("ID to fetch the job status counts.")] string Id,
CancellationToken cancellationToken = default)
{
try
{
//Add progress report to say that task has started
await Task.Delay(TimeSpan.FromMinutes(5));
//Add progress report to say this has ended
}
}
Beta Was this translation helpful? Give feedback.
All reactions