Skip to content

Conversation

samedson
Copy link
Contributor

Co-authored-by: Konstantin Mandrika kmandrika@google.com

Description

Add MCP init prompts for Firestore and AI Logic

Scenarios Tested

NA

Sample Commands

/firebase:init --prompt="Build an app that gets the weather and converts it to its most appropriate emoji and stores them in a database"

Copy link
Contributor

Summary of Changes

Hello @samedson, 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 significantly enhances the Firebase initialization experience within the MCP by introducing more structured and detailed prompts and guides. It streamlines the setup for core Firebase services, particularly for AI Logic, Firestore, Authentication, and Hosting, by providing comprehensive instructions and code examples tailored for various platforms and AI assistant interactions.

Highlights

  • Enhanced Firebase Initialization Flow: The core Firebase initialization prompt (init.ts) has been updated to include more robust steps for handling Firebase project creation/selection and SDK initialization, ensuring a smoother setup process.
  • Comprehensive AI Logic Setup Guide: A detailed guide for setting up Firebase AI Logic (Gemini CLI rules) has been added, replacing a previous placeholder. This guide includes prerequisites, step-by-step setup instructions, and extensive code snippets for various platforms and AI features like text generation, multimodal input, and image manipulation.
  • New Authentication Setup Guide: A dedicated guide (init_auth.ts) has been introduced to walk users through configuring Firebase Authentication, covering provider setup, implementation, security rules, and testing.
  • New Hosting Setup Guide: A new guide (init_hosting.ts) is now available for configuring Firebase Hosting, providing instructions for deploying applications to production.
  • Updated Backend Initialization Guidance: The init_backend guide has been refined to explicitly direct users to the new Firestore, Authentication, and Hosting guides, and now includes a comprehensive commented-out section with detailed Firebase setup guidelines specifically for AI assistants.
  • Expanded Firestore Setup Guide: The Firestore setup guide (init_firestore.ts) has been significantly expanded with more detailed instructions on database provisioning, CRUD operations, verification, testing, and security rules, including example security rules.
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.

Co-authored-by: Konstantin Mandrika <kmandrika@google.com>
@samedson samedson force-pushed the samedson-init-prompt branch from dd00ec8 to 127abc0 Compare September 24, 2025 14:52
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 introduces new MCP init prompts and detailed guides for Firestore and AI Logic, significantly enhancing the instructions for the AI agent. The changes are well-structured and provide comprehensive steps for setting up various Firebase services. My review includes a few suggestions to fix typos in the prompt text and remove large blocks of commented-out code to improve maintainability. Overall, these new prompts are a valuable addition.

Copy link
Contributor

@joehan joehan left a comment

Choose a reason for hiding this comment

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

Put in some thoughts on the content, but lets just get this in and then we can test those changes later

| :--- | ---: | :--- | :--- |
| Swift iOS | Generate text from text-only input | Gemini Developer API (Developer API) | import FirebaseAI// Initialize the Gemini Developer API backend servicelet ai = FirebaseAI.firebaseAI(backend: .googleAI())// Create a \`GenerativeModel\` instance with a model that supports your use caselet model = ai.generativeModel(modelName: "gemini-2.5-flash")// Provide a prompt that contains textlet prompt = "Write a story about a magic backpack."// To generate text output, call generateContent with the text inputlet response = try await model.generateContent(prompt)print(response.text ?? "No text in response.")|
| Kotlin Android | Generate text from text-only input | Gemini Developer API (Developer API) | // Initialize the Gemini Developer API backend service// Create a \`GenerativeModel\` instance with a model that supports your use caseval model = Firebase.ai(backend = GenerativeBackend.googleAI()) .generativeModel("gemini-2.5-flash")// Provide a prompt that contains textval prompt = "Write a story about a magic backpack."// To generate text output, call generateContent with the text inputval response = generativeModel.generateContent(prompt)print(response.text) |
| Java Android | Generate text from text-only input | Gemini Developer API (Developer API) | // Initialize the Gemini Developer API backend service// Create a \`GenerativeModel\` instance with a model that supports your use caseGenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI()) .generativeModel("gemini-2.5-flash");// Use the GenerativeModelFutures Java compatibility layer which offers// support for ListenableFuture and Publisher APIsGenerativeModelFutures model = GenerativeModelFutures.from(ai);// Provide a prompt that contains textContent prompt = new Content.Builder() .addText("Write a story about a magic backpack.") .build();// To generate text output, call generateContent with the text inputListenableFuture<GenerateContentResponse> response = model.generateContent(prompt);Futures.addCallback(response, new FutureCallback<GenerateContentResponse>() { @Override public void onSuccess(GenerateContentResponse result) { String resultText = result.getText(); System.out.println(resultText); } @Override public void onFailure(Throwable t) { t.printStackTrace(); }}, executor); |
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to act on this right away:

Long term, it feels like each of the cases should be it's own guide, and this guide should point the prompt at the correct one to read. Otherwise, we're dumping a ton of info into the context and I worry it may cause confusion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great idea. I think Andrew and team might be working on a more complete version of this prompt, so we can pass that idea along

- Introduce Firebase Hosting when developers are ready to deploy their application to production
- **Alternative**: Developers can deploy later using the \`/deploy\` command
- **Permission Required**: Request developer permission before implementing Firebase Hosting
- **Deployment**: Configure Firebase Hosting and deploy the application to production
Copy link
Contributor

Choose a reason for hiding this comment

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

Nonblocking note for later - does this actually work? Seems like we'd want more explicit instructions on how to do this...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my thought too. We're starting with Charlotte's prompts for now, but we'll likely iterate on this. Surprisingly this works decently well

- **Verification**: Guide developers to verify database creation at the [Firebase Console](https://console.firebase.google.com/) by clicking on the "Firestore Database" tab in the left navigation to confirm the database is created.
- **Testing**: Recommend developers test their application and verify data appears correctly in the console. Ask developers to confirm they can see their test data in the console before proceeding to the next step.
- **Security**: Recommend implementing authentication if the application handles sensitive user data. Guide users to navigate to the "Firestore Database" section and click on the "Rules" tab to view and configure their security rules.
- **Security Warning**: Alert developers against making Firestore security rules public (allowing read/write without authentication)
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for later: there's a really thorough prompt in studio about how to make secure rules - we might want to pull that into here as another guide, and link the AI to it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'm hoping to bring that in and add a bunch more rules tooling soon

2. Use the Firebase \`read_resources\` tool to load the guide to setup the product you choose.
## Available Services
The user will likely need to setup Firestore, Authentication, and Hosting. Read the following guides in order. Do not run the app until you have completed all 3 guides.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nonblocking thing to test: should this instead tell the AI to run the init MCP tool with Firestore, Auth, and Hosting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooh hadn't seen that tool - let me check that out in a follow up

@samedson
Copy link
Contributor Author

Added this feedback to our task list. Gonna merge for now to have a v0 in for bug bash

@samedson samedson enabled auto-merge (squash) September 24, 2025 18:38
@samedson samedson merged commit 8b76c67 into master Sep 24, 2025
48 checks passed
@samedson samedson deleted the samedson-init-prompt branch September 24, 2025 18:48
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions Sep 24, 2025
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