From a55006b810b8de63d72c0a34e78c2fb9155b0d5d Mon Sep 17 00:00:00 2001 From: Yaojia Wang Date: Sun, 23 Nov 2025 15:32:04 +0100 Subject: [PATCH] fix(backend): Use tenant_id claim name in MCP API Key authentication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed TenantId claim name mismatch between McpApiKeyAuthenticationHandler and ITenantContext implementations. Changed claim name from "TenantId" to "tenant_id" to match what TenantContext.GetCurrentTenantId() expects. This fixes the "TenantId cannot be empty" error when MCP SDK Resources attempt to retrieve the tenant ID after API Key authentication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../Authentication/McpApiKeyAuthenticationHandler.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/colaflow-api/src/Modules/Mcp/ColaFlow.Modules.Mcp.Infrastructure/Authentication/McpApiKeyAuthenticationHandler.cs b/colaflow-api/src/Modules/Mcp/ColaFlow.Modules.Mcp.Infrastructure/Authentication/McpApiKeyAuthenticationHandler.cs index 00a2b8f..4818bbb 100644 --- a/colaflow-api/src/Modules/Mcp/ColaFlow.Modules.Mcp.Infrastructure/Authentication/McpApiKeyAuthenticationHandler.cs +++ b/colaflow-api/src/Modules/Mcp/ColaFlow.Modules.Mcp.Infrastructure/Authentication/McpApiKeyAuthenticationHandler.cs @@ -48,11 +48,12 @@ public class McpApiKeyAuthenticationHandler : AuthenticationHandler { new(ClaimTypes.NameIdentifier, validationResult.UserId.ToString()), new("ApiKeyId", validationResult.ApiKeyId.ToString()), - new("TenantId", validationResult.TenantId.ToString()), + new("tenant_id", validationResult.TenantId.ToString()), new("UserId", validationResult.UserId.ToString()), };