---
title: "Connect while to Codex over MCP to deploy your apps"
url: https://while.sh/en/guides/connect-codex/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-02
---

# Connect while to Codex over MCP, to deploy your apps

Codex already writes your app. Connected to while over MCP, in two commands, it deploys it too, with its database and its access settings, and asks for your approval for what matters.

## Prerequisites

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

## Step 1: Connect while to Codex

In a terminal, add while to Codex's MCP servers, then sign in (source 1):

```sh titre="Terminal"
codex mcp add while --url https://app.while.sh/mcp
codex mcp login while
```

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

The second command opens a page in your browser: choose "A new app", then click Authorize. Without a browser, add `--no-browser`: open the address it displays on a device that has a browser, then paste into the terminal the address you're sent back to.

## What your agent does

Codex then sees while's tools: deploy, create a database, read the logs, query the database, open a preview, roll back. It calls them when you ask, with your permissions.

## 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 sign-ups 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, 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. [Codex, MCP servers](https://learn.chatgpt.com/docs/extend/mcp?surface=cli), 2026-11-02

## Questions

### Do I need a token?

No: your agent gets authorized 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?

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