namespace ModelContextProtocol.Server;
///
/// Represents the execution context for a task being executed by the server.
/// This context flows with async execution and enables automatic task status updates.
///
internal sealed class TaskExecutionContext
{
///
/// Gets the AsyncLocal instance used to track the current task execution context.
///
private static readonly AsyncLocal s_current = new();
///
/// Gets or sets the current task execution context for the executing async flow.
///
public static TaskExecutionContext? Current
{
get => s_current.Value;
set => s_current.Value = value;
}
///
/// Gets the task ID of the currently executing task.
///
public required string TaskId { get; init; }
///
/// Gets the session ID associated with the task.
///
public string? SessionId { get; init; }
///
/// Gets the task store used to persist task state.
///
public required IMcpTaskStore TaskStore { get; init; }
///
/// Gets whether task status notifications should be sent.
///
public bool SendNotifications { get; init; }
///
/// Gets or sets the function to call when sending a task status notification.
///
public Func? NotifyTaskStatusFunc { get; init; }
}