Skip to content

Fixing bad implementation of isFirebaseMCP#9985

Open
joehan wants to merge 2 commits intomainfrom
jh-fix-mcp-detection
Open

Fixing bad implementation of isFirebaseMCP#9985
joehan wants to merge 2 commits intomainfrom
jh-fix-mcp-detection

Conversation

@joehan
Copy link
Member

@joehan joehan commented Feb 26, 2026

Description

Previously, we were setting this header before we ran the code to set this env var.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @joehan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical timing issue where the IS_FIREBASE_MCP environment variable was not consistently set before STANDARD_HEADERS were initialized, leading to incorrect user-agent strings in API requests. The changes ensure that header generation is dynamic and that the Firebase MCP state is managed through a dedicated, internal flag, guaranteeing accurate header information when API calls are made.

Highlights

  • Dynamic Header Generation: Converted the STANDARD_HEADERS constant object into an exported function to ensure that user-agent components, such as the Firebase MCP status, are evaluated dynamically at the time of header creation rather than at module initialization.
  • Centralized Firebase MCP State Management: Refactored the isFirebaseMcp function to rely on an internal boolean flag (isFirebaseMcpFlag) instead of directly checking process.env.IS_FIREBASE_MCP. A new setFirebaseMcp function was introduced to explicitly control this flag, improving state management.
  • Updated MCP Initialization: Modified src/bin/mcp.ts to use the newly introduced setFirebaseMcp(true) function, replacing the direct assignment to process.env.IS_FIREBASE_MCP, for consistent and controlled state updates.
  • Consistent Header Usage: Adjusted all instances where STANDARD_HEADERS were used, such as in src/apiv2.ts and src/gcp/cloudsql/fbToolsAuthClient.ts, to call it as a function (STANDARD_HEADERS()) to retrieve the dynamically generated headers.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/apiv2.ts
    • Converted STANDARD_HEADERS from a constant object to an exported function that returns the header record.
    • Updated the Client class to call STANDARD_HEADERS() when setting default request headers.
  • src/bin/mcp.ts
    • Imported the setFirebaseMcp function from ../env.
    • Replaced the direct assignment process.env.IS_FIREBASE_MCP = "true" with a call to setFirebaseMcp(true).
  • src/env.ts
    • Introduced a private isFirebaseMcpFlag variable to manage the Firebase MCP state.
    • Modified isFirebaseMcp to return the value of isFirebaseMcpFlag.
    • Added an exported setFirebaseMcp function to update the isFirebaseMcpFlag.
  • src/gcp/cloudsql/fbToolsAuthClient.ts
    • Updated getRequestHeaders to call apiv2.STANDARD_HEADERS() instead of spreading the constant object.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes an issue where headers were being generated before the necessary environment configuration was set. The change from a constant STANDARD_HEADERS object to a function is a good approach. I've found one critical syntax issue due to formatting which should be addressed.

src/apiv2.ts Outdated
"User-Agent": clientVersion,
"X-Client-Version": clientVersion,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This closing brace has incorrect indentation and is missing a semicolon at the end of the const declaration, which will cause a syntax error. Per the repository's GEMINI.md style guide, you can run npm run format to automatically fix such issues.

Suggested change
}
};
References
  1. The repository style guide (line 21) suggests running npm run format to auto-fix formatting issues. This line contains a formatting error that also results in a syntax error. (link)

@joehan joehan requested a review from chkuang-g February 27, 2026 02:13
@chkuang-g chkuang-g changed the title Fixing bad implementation of isFirebaseMCPP Fixing bad implementation of isFirebaseMCP Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants