Skip to content
CLI tool · Cloud & deploy

Firebase CLI for AI agents

The Firebase CLI for AI agents: list projects, run the local emulators, deploy hosting previews, and read function logs, with the deploys to avoid.

firebaseby Google (Firebase)Official MCP option
What it is

What Firebase CLI does for an agent

The Firebase CLI, distributed as the firebase-tools package, is Google's official tool for Firebase projects. It runs the Local Emulator Suite, deploys Hosting, Cloud Functions, and security rules, and manages preview channels.

The emulators let an agent test Firestore rules, Auth flows, and functions locally, so most work never needs to touch a live project.

Official site: firebase.google.com

Install

Install Firebase CLI

The install commands from the official docs. Check it worked with firebase --version.

npm (global)
npm install -g firebase-tools
Standalone binary (macOS, Linux)
curl -sL https://firebase.tools | bash
Auth

Signing in Firebase CLI for an agent

A human signs in with firebase login. In CI, Firebase recommends service account credentials through GOOGLE_APPLICATION_CREDENTIALS rather than personal tokens.

Check the sign-in (read-only)
firebase login:list
Interactive sign-in (human)
firebase login
Pick the project for this directory
firebase use my-project

Environment variables: GOOGLE_APPLICATION_CREDENTIALS. Set them in the agent's environment; never paste values into prompts or commit them.

Common agent tasks

What agents use Firebase CLI for

Example commands with placeholder names. Swap in your own project, app, or file names.

  1. List projects

    firebase
    firebase projects:list
  2. Start the local emulators

    firebase
    firebase emulators:start

    Long-running. Start it in the background, or wrap tests with firebase emulators:exec.

  3. Run tests against the emulators

    firebase
    firebase emulators:exec "npm test"
  4. Deploy a Hosting preview channel

    firebase
    firebase hosting:channel:deploy preview

    Creates a temporary URL; the live site is unchanged.

  5. Read Cloud Functions logs

    firebase
    firebase functions:log
Safety

Safety rules for agents

Safe to run without asking

  • firebase login:list
  • firebase projects:list
  • firebase functions:log
  • firebase emulators:start / emulators:exec

Ask a human first

  • firebase deploy
  • firebase deploy --only firestore:rules
  • firebase firestore:delete
  • firebase hosting:disable
  • Never run firebase deploy without --only; a bare deploy ships every target, including security rules.
  • Pass --project explicitly or check .firebaserc so the agent never deploys to the wrong project.
  • Test rule and function changes in the emulators before proposing a deploy.
Agent instructions

AGENTS.md or CLAUDE.md snippet

Paste this into the instruction file your agent reads at the start of every session, then adjust the rules to your setup.

AGENTS.md
## Firebase CLI (firebase)

Use `firebase` for running Firebase emulators, deploying preview channels, and reading Cloud Functions logs.

- Check it is installed with `firebase --version`. If it is missing, ask before installing it.
- Auth: a human signs firebase in. Check with `firebase login:list`; if it fails, stop and ask. Never run the login flow yourself, and never print tokens (GOOGLE_APPLICATION_CREDENTIALS).
- Run without asking (read-only): `firebase login:list`, `firebase projects:list`, `firebase functions:log`, `firebase emulators:start / emulators:exec`.
- Ask a human first (changes or deletes things): `firebase deploy`, `firebase deploy --only firestore:rules`, `firebase firestore:delete`, `firebase hosting:disable`.
- Never run firebase deploy without --only; a bare deploy ships every target, including security rules.
- Pass --project explicitly or check .firebaserc so the agent never deploys to the wrong project.
- Test rule and function changes in the emulators before proposing a deploy.
- Prefer JSON output where the command supports it, and keep output short.
CLI or MCP server?

Firebase CLI or an MCP server?

An official MCP option exists. The Firebase CLI includes an official MCP server, started with firebase-tools' mcp command, that exposes project, Auth, Firestore, and rules tools. Use it for MCP clients; use the CLI directly in a shell-based agent.

Rule of thumb: in a terminal agent that a human has signed in, the CLI is usually faster and cheaper in context. In a chat client without a shell, or when you want a fixed set of typed tools, use an MCP server.

Same category
All Cloud & deploy tools
FAQ

Firebase CLI questions

How do I install Firebase CLI?

npm (global): npm install -g firebase-tools. Other official options: Standalone binary (macOS, Linux). Check the install with firebase --version, and see the Google (Firebase) docs for other platforms.

How does an AI agent authenticate Firebase CLI?

A human signs in with firebase login. In CI, Firebase recommends service account credentials through GOOGLE_APPLICATION_CREDENTIALS rather than personal tokens. The agent can check the sign-in with firebase login:list and should stop and ask if it fails.

Which Firebase CLI commands are safe for an agent to run?

Commands that only read state are safe to run without asking: firebase login:list; firebase projects:list; firebase functions:log; firebase emulators:start / emulators:exec. Ask a human before anything that changes or deletes something: firebase deploy; firebase deploy --only firestore:rules; firebase firestore:delete; firebase hosting:disable.

Is there an MCP server for Firebase CLI?

The Firebase CLI includes an official MCP server, started with firebase-tools' mcp command, that exposes project, Auth, Firestore, and rules tools. Use it for MCP clients; use the CLI directly in a shell-based agent.