feat(mcp): add TaskRunMcpContext + accessor

This commit is contained in:
mika kuns
2026-06-04 15:50:30 +02:00
parent ef86a8c29b
commit 7542bc2058

View File

@@ -0,0 +1,20 @@
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.");
}