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.