diff --git a/colaflow-api/src/Modules/Mcp/ColaFlow.Modules.Mcp.Application/Services/PendingChangeService.cs b/colaflow-api/src/Modules/Mcp/ColaFlow.Modules.Mcp.Application/Services/PendingChangeService.cs index cb7da5f..90a850a 100644 --- a/colaflow-api/src/Modules/Mcp/ColaFlow.Modules.Mcp.Application/Services/PendingChangeService.cs +++ b/colaflow-api/src/Modules/Mcp/ColaFlow.Modules.Mcp.Application/Services/PendingChangeService.cs @@ -34,7 +34,9 @@ public class PendingChangeService( var tenantId = _tenantContext.GetCurrentTenantId(); // Get API Key ID from HttpContext (set by MCP authentication middleware) - var apiKeyIdNullable = _httpContextAccessor.HttpContext?.Items["ApiKeyId"] as Guid?; + // Check both "McpApiKeyId" (from McpApiKeyAuthenticationHandler) and "ApiKeyId" (from legacy middleware) + var apiKeyIdNullable = _httpContextAccessor.HttpContext?.Items["McpApiKeyId"] as Guid? + ?? _httpContextAccessor.HttpContext?.Items["ApiKeyId"] as Guid?; if (!apiKeyIdNullable.HasValue) { throw new McpUnauthorizedException("API Key not found in request context");