Implement SEP-2663 Tasks Extension (#1579)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
ed07fdb6f4
commit
dbb7a20176
1 changed files with 8190 additions and 11405 deletions
|
|
@ -97,34 +97,40 @@ public sealed class McpClientOptions
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the task store for managing client-side tasks.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// When a task store is configured, the client will support task-augmented requests from the server.
|
||||
/// This allows the server to request sampling or elicitation as tasks, which the client executes
|
||||
/// asynchronously and allows the server to poll for status and results.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If not set, task-augmented requests will not be supported, and the client will not advertise
|
||||
/// task capabilities to the server.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Experimental(Experimentals.Tasks_DiagnosticId, UrlFormat = Experimentals.Tasks_Url)]
|
||||
public IMcpTaskStore? TaskStore { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the client should send task status notifications to the server.
|
||||
/// Gets or sets the maximum number of consecutive task polls during which a task may report
|
||||
/// <see cref="McpTaskStatus.InputRequired"/> without publishing any new input requests, before
|
||||
/// the client treats the task as stuck, issues a best-effort <c>tasks/cancel</c>, and throws
|
||||
/// an <see cref="McpException"/>.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <see langword="true"/> to send task status notifications; <see langword="false"/> otherwise.
|
||||
/// The default is <see langword="true"/>.
|
||||
/// The maximum number of consecutive stuck polls allowed. The default value is <c>60</c>.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// When enabled and a <see cref="TaskStore"/> is configured, the client will send optional
|
||||
/// <c>notifications/tasks/status</c> notifications to inform the server of task state changes.
|
||||
/// Servers MUST NOT rely on receiving these notifications and should continue polling via <c>tasks/get</c>.
|
||||
/// <para>
|
||||
/// This guard prevents an unbounded poll loop when the server keeps a task in
|
||||
/// <see cref="McpTaskStatus.InputRequired"/> but never publishes new input requests after the
|
||||
/// client has already responded to every previously surfaced request. It only affects the
|
||||
/// long-poll path used by <see cref="McpClient.CallToolAsync(CallToolRequestParams, CancellationToken)"/>;
|
||||
/// it does not affect direct <see cref="McpClient.GetTaskAsync(string, CancellationToken)"/> calls.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Callers should size this value with the configured server-side poll interval in mind: the
|
||||
/// effective wall-clock timeout is roughly <c>MaxConsecutiveStuckPolls * pollIntervalMs</c>.
|
||||
/// Setting this to a very small value can cause false positives for servers that are slow to
|
||||
/// surface follow-up input requests; setting it too large can mask misbehaving servers.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Experimental(Experimentals.Tasks_DiagnosticId, UrlFormat = Experimentals.Tasks_Url)]
|
||||
public bool SendTaskStatusNotifications { get; set; } = true;
|
||||
/// <exception cref="ArgumentOutOfRangeException">The value is less than <c>1</c>.</exception>
|
||||
public int MaxConsecutiveStuckPolls
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (value < 1)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, "must be greater than or equal to 1.");
|
||||
}
|
||||
field = value;
|
||||
}
|
||||
} = 60;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue