Files
ClaudeDo/src/ClaudeDo.Worker/Runner/TaskRunMcpContext.cs
2026-06-04 15:50:30 +02:00

21 lines
693 B
C#

using Microsoft.AspNetCore.Http;
namespace ClaudeDo.Worker.Runner;
// Per-request caller identity for the task-run MCP surface, populated by the auth
// middleware from the run's token (mirrors PlanningMcpContext).
public sealed class TaskRunMcpContext
{
public required string CallerTaskId { get; init; }
}
public sealed class TaskRunMcpContextAccessor
{
private readonly IHttpContextAccessor _http;
public TaskRunMcpContextAccessor(IHttpContextAccessor http) => _http = http;
public TaskRunMcpContext Current =>
(_http.HttpContext?.Items["TaskRunContext"] as TaskRunMcpContext)
?? throw new InvalidOperationException("No task-run context on request.");
}