---
title: "Connect while to Gemini CLI over MCP, in one command"
url: https://while.sh/en/guides/connect-gemini-cli/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-02
---

# Connect while to Gemini CLI over MCP to deploy your apps

Gemini CLI already writes your app. Connected to while over MCP with one command, it also deploys it, with its database and its access rules, and it asks for your approval for what matters.

## Prerequisites

- Gemini CLI, installed on your computer.
- A browser, to authorize your agent once.

## Step 1: Connect while to Gemini CLI

In a terminal, run this command (source 1):

```sh titre="Terminal"
gemini mcp add --scope user --transport http while https://app.while.sh/mcp
```

Or let your agent do it: paste "Connect to while with my account (while.sh/agents), then deploy my app." into it, and it connects itself.

## Step 2: Authorize it in your browser

On the first call to while, a page opens in your browser. Choose "A new app", then click Authorize.

## What your agent does

Gemini CLI then sees while's tools: deploy, create a database, read the logs, query the database, open a preview and roll back. It asks for your approval before it calls a tool.

## Deploy your app

> You, to your agent: Deploy my app with while.

Your agent writes while.yaml, sends the code, and gives you your app's address, over HTTPS. The details are in the guides, from Next.js to Django.

## Understand an error

> You, to your agent: Why has the app been returning errors since this morning?

Your agent reads the logs and the grouped errors in while, finds the cause and fixes it.

## Query your database

> You, to your agent: How many people signed up this week?

Your agent reads your database in SQL over MCP, with your permissions on the data, and it can't write to it.

## See a new version before you deploy it

> You, to your agent: Show me the new version before you deploy it.

Your agent opens a preview, at its own address, with its own data. You look at it, and then your agent puts it into production.

## Go back to the previous version

> You, to your agent: Go back to the previous version.

In the 30 minutes after a deployment, the previous version comes back in a second. After that, it takes a few seconds. Once the previous version is back, your agent reads what broke in while's logs, fixes it and deploys again.

## Connect all the agents on your computer

> You, to your agent: Connect while to all my agents.

One command connects Claude Code, Codex, Cursor, Gemini CLI and VS Code at once. Read the script first, if you like:

```sh titre="Terminal"
curl -fsSL https://app.while.sh/install.sh | sh
```

## Next steps

- [Deploy a Node.js API and its PostgreSQL database](/en/guides/deploy-node-api-postgresql/)
- [Deploy a Next.js app](/en/guides/deploy-nextjs/)
- [Compare the hosts that have an MCP server](/en/comparisons/mcp-hosting-claude-code/)

## Sources

1. [Gemini CLI, MCP servers](https://geminicli.com/docs/tools/mcp-server/), 2026-11-02

## Questions

### Do I need a token?

No: your agent authorizes itself in your browser, once. For a CI without a browser, a token takes its place: your agent creates it, and you confirm it in one click.

### Does my agent see my keys?

No: your keys stay in while, and calls to an external API go through while, which adds the key.

### What can my agent do without me?

It can deploy, and read the logs and the database. Sensitive actions, like deleting a production database, wait for your approval.
