From 2beefbee3f6321ce12116d7ce68485db2d76317f Mon Sep 17 00:00:00 2001 From: Joe Hanley Date: Mon, 28 Jul 2025 15:11:41 -0700 Subject: [PATCH] Fixing an issue where MCP server wuld still hang on studio instead of asking for firebase login --- src/mcp/errors.ts | 8 +++++++- src/mcp/index.ts | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mcp/errors.ts b/src/mcp/errors.ts index d0b2c97be05..00a007b3bec 100644 --- a/src/mcp/errors.ts +++ b/src/mcp/errors.ts @@ -6,8 +6,14 @@ export const NO_PROJECT_ERROR = mcpError( "PRECONDITION_FAILED", ); -export function mcpAuthError(): CallToolResult { +export function mcpAuthError(skipADC: boolean): CallToolResult { const cmd = commandExistsSync("firebase") ? "firebase" : "npx -y firebase-tools"; + if (skipADC) { + return mcpError(`The user is not currently logged into the Firebase CLI, which is required to use this tool. Please instruct the user to execute this shell command to sign in. +\`\`\`sh +${cmd} login +\`\`\``); + } return mcpError(`The user is not currently logged into the Firebase CLI, which is required to use this tool. Please instruct the user to execute this shell command to sign in or to configure [Application Default Credentials][ADC] on their machine. \`\`\`sh ${cmd} login diff --git a/src/mcp/index.ts b/src/mcp/index.ts index 2db4c521a59..4cedebb9655 100644 --- a/src/mcp/index.ts +++ b/src/mcp/index.ts @@ -283,9 +283,10 @@ export class FirebaseMcpServer { projectId = projectId || ""; // Check if the user is logged in. - const accountEmail = await this.getAuthenticatedUser(); + const skipAutoAuthForStudio = isFirebaseStudio(); + const accountEmail = await this.getAuthenticatedUser(skipAutoAuthForStudio); if (tool.mcp._meta?.requiresAuth && !accountEmail) { - return mcpAuthError(); + return mcpAuthError(skipAutoAuthForStudio); } // Check if the tool requires Gemini in Firebase API.