Skip to content

Commit f6c9ed1

Browse files
authored
Fixing an issue where MCP server wuld still hang on studio instead of asking for firebase login (#8903)
1 parent ad6e8da commit f6c9ed1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/mcp/errors.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ export const NO_PROJECT_ERROR = mcpError(
66
"PRECONDITION_FAILED",
77
);
88

9-
export function mcpAuthError(): CallToolResult {
9+
export function mcpAuthError(skipADC: boolean): CallToolResult {
1010
const cmd = commandExistsSync("firebase") ? "firebase" : "npx -y firebase-tools";
11+
if (skipADC) {
12+
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.
13+
\`\`\`sh
14+
${cmd} login
15+
\`\`\``);
16+
}
1117
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.
1218
\`\`\`sh
1319
${cmd} login

src/mcp/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,10 @@ export class FirebaseMcpServer {
283283
projectId = projectId || "";
284284

285285
// Check if the user is logged in.
286-
const accountEmail = await this.getAuthenticatedUser();
286+
const skipAutoAuthForStudio = isFirebaseStudio();
287+
const accountEmail = await this.getAuthenticatedUser(skipAutoAuthForStudio);
287288
if (tool.mcp._meta?.requiresAuth && !accountEmail) {
288-
return mcpAuthError();
289+
return mcpAuthError(skipAutoAuthForStudio);
289290
}
290291

291292
// Check if the tool requires Gemini in Firebase API.

0 commit comments

Comments
 (0)