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.
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 Firebase CLI
The install commands from the official docs. Check it worked with firebase --version.
npm install -g firebase-tools
curl -sL https://firebase.tools | bash
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.
firebase login:list
firebase login
firebase use my-project
Environment variables: GOOGLE_APPLICATION_CREDENTIALS. Set them in the agent's environment; never paste values into prompts or commit them.
What agents use Firebase CLI for
Example commands with placeholder names. Swap in your own project, app, or file names.
List projects
firebase projects:list
Start the local emulators
firebase emulators:start
Long-running. Start it in the background, or wrap tests with firebase emulators:exec.
Run tests against the emulators
firebase emulators:exec "npm test"
Deploy a Hosting preview channel
firebase hosting:channel:deploy preview
Creates a temporary URL; the live site is unchanged.
Read Cloud Functions logs
firebase functions:log
Safety rules for agents
Safe to run without asking
firebase login:listfirebase projects:listfirebase functions:logfirebase emulators:start / emulators:exec
Ask a human first
firebase deployfirebase deploy --only firestore:rulesfirebase firestore:deletefirebase 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.
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.
## 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.
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.
Other Cloud & deploy tools
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.