Leave Fly.io without rewriting your app, from your AI agent
Your customers want their data in France, or you want an agent that deploys for you? Connected to while over MCP, it takes over your Fly.io app as is, copies the database and deploys it.
By Aloïs Oddon, co-founder of Nextmap. Facts checked on November 5, 2026.
Prerequisites
- An app on Fly.io, with its fly.toml.
- The Fly.io command line, to export the database.
- An AI agent that works in a terminal: Claude Code, Codex, Cursor or Gemini CLI.
Step 1: Give your agent these instructions
Open your agent in your app’s folder and paste these instructions into it:
Connect to while with my account (while.sh/agents), then deploy my app.
With your account, your agent adds while’s MCP server itself. On the first call to while, a page opens in your browser: choose “A new app”, then click Authorize.
Step 2: Open your app
Your agent gives you your app’s address, for example https://mon-appli.while.cloud, over HTTPS.
What your agent does
It reads your fly.toml and carries its settings over to while.yaml1:
| In fly.toml | In while.yaml |
|---|---|
internal_port in [http_service] | the service’s port, port |
path in its checks | the health path, health.path |
[processes], like web and worker | one service per process, type: worker for those without an address |
memory and cpus in [[vm]] | the service’s resources, resources |
min_machines_running = 0 | sleep, sleep |
[env] | the service’s variables, env |
apiVersion: while/v1
project: mon-appli
services:
- name: web
port: 8080
health:
path: /health
- name: worker
type: worker
command: [bin/worker]
databases:
- name: main
Copy your PostgreSQL database
You, to your agent: Copy our Fly database to while.
Your agent opens a tunnel to the database with fly mpg proxy, exports it with pg_dump3, then loads it into while.
Take over your secrets
You, to your agent: Take over our Fly secrets.
Fly.io never returns a secret’s value2: your agent lists their names, and you enter the values yourself in while. Your agent never sees them.
Move to your own domain
You, to your agent: Put the app on www.acme.com.
Your agent declares the domain, you add the DNS records it gives you, and the HTTPS certificate follows.
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.
In the docs: PostgreSQL databases, Worker, Custom domain, Versions and rollback and Variables and secrets.
Next steps
Sources
- Fly.io, app configuration (fly.toml), accessed November 5, 2026
- Fly.io, app secrets, accessed November 5, 2026
- Fly.io, Managed Postgres and its tunnel (fly mpg proxy), accessed November 5, 2026