diff --git a/lib/mcp/verifyApiKey.ts b/lib/mcp/verifyApiKey.ts index 8cf3d91..20afdbd 100644 --- a/lib/mcp/verifyApiKey.ts +++ b/lib/mcp/verifyApiKey.ts @@ -25,6 +25,7 @@ export async function verifyBearerToken( bearerToken?: string, ): Promise { if (!bearerToken) { + console.error("[MCP Auth] No bearer token provided"); return undefined; } @@ -32,6 +33,7 @@ export async function verifyBearerToken( try { const accountId = await getAccountIdByAuthToken(bearerToken); + console.log("[MCP Auth] Privy JWT validated, accountId:", accountId); return { token: bearerToken, scopes: ["mcp:tools"], @@ -41,8 +43,11 @@ export async function verifyBearerToken( orgId: null, }, }; - } catch { - // Privy validation failed, try API key + } catch (privyError) { + console.log( + "[MCP Auth] Privy JWT validation failed:", + privyError instanceof Error ? privyError.message : privyError, + ); } // Try API key validation @@ -50,9 +55,11 @@ export async function verifyBearerToken( const accountId = await getAccountIdByApiKey(bearerToken); if (!accountId) { + console.error("[MCP Auth] API key validation returned no accountId"); return undefined; } + console.log("[MCP Auth] API key validated, accountId:", accountId); return { token: bearerToken, scopes: ["mcp:tools"], @@ -62,7 +69,11 @@ export async function verifyBearerToken( orgId: null, }, }; - } catch { + } catch (apiKeyError) { + console.error( + "[MCP Auth] API key validation failed:", + apiKeyError instanceof Error ? apiKeyError.message : apiKeyError, + ); return undefined; } }