---
title: "Self-host Directus in France over MCP, with while.sh"
url: https://while.sh/en/guides/self-host-directus/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-03
---

# Self-host Directus in France, with its PostgreSQL database, from your AI agent

A back office and an API for your content, with no server to maintain. Connected to while over MCP, your AI agent deploys Directus in France, with its content in a PostgreSQL database backed up every day.

## Prerequisites

- A new Directus instance, or your exported schema.
- Your AI agent: Claude Code, Codex, Cursor or Gemini CLI.

## Step 1: Ask your agent for Directus

> You, to your agent: Connect to while with my account (while.sh/agents), then deploy Directus with its PostgreSQL database.

Your agent adds while's MCP server itself. If it asks you to, restart it. On the first call to while, a page opens in your browser. In Claude Code, if it doesn't open, type /mcp, choose while, then Authenticate. On that page, choose "A new app", then click Authorize.

## Step 2: Open your back office

Your agent gives you your Directus address, for example `https://directus.while.cloud`, with the admin account's email address and password. Sign in, change that password, then create your collections.

## What your agent does

Directus reads its database from `DB_CONNECTION_STRING` (source 1), and while provides it in `DATABASE_URL`. So your agent writes a Dockerfile, on the official Directus image, that copies one into the other at startup:

```dockerfile titre="Dockerfile"
FROM directus/directus:11
ENV PORT=8080 HOST=0.0.0.0
CMD ["sh", "-c", "export DB_CONNECTION_STRING=\"$DATABASE_URL\"; node cli.js bootstrap && pm2-runtime start ecosystem.config.cjs"]
```

Then while.yaml:

```yaml titre="while.yaml"
apiVersion: while/v1
project: directus
services:
  - name: web
    port: 8080
    health: { path: /server/health }
databases:
  - name: main
```

At startup, `node cli.js bootstrap` creates the Directus tables and the admin account, then Directus answers on `/server/health`. Your agent sets Directus's `KEY` and `SECRET` keys and the admin password in while as secrets (source 3), and sets `ADMIN_EMAIL`, `DB_CLIENT: pg` and `TELEMETRY: false` in plain text.

## Move to your own domain

> You, to your agent: Put Directus on cms.acme.com.

Your agent declares the domain, you add the DNS records it gives you, and the HTTPS certificate follows.

## Upgrade to the latest version of Directus

> You, to your agent: Upgrade Directus to the latest version.

Your agent deploys the latest Directus image. If the new version disappoints, it rolls back to the previous one.

## Put Directus back the way it was yesterday

> You, to your agent: Restore Directus's database to yesterday at 6 pm.

Your agent prepares the restore, and you approve it: a safety backup is taken first, then the database goes back to the requested moment.

## Read your content from your agent

> You, to your agent: How many articles were published this month?

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

## Next steps

- [Deploy Strapi and its PostgreSQL database](/en/guides/deploy-strapi/)
- [Restore your database to a precise moment](/en/guides/restore-postgresql/)

## Sources

1. [Directus, database configuration](https://directus.com/docs/configuration/database), 2026-11-02
2. [Directus, file storage](https://directus.com/docs/configuration/files), 2026-11-02
3. [Directus, security (SECRET)](https://directus.com/docs/configuration/security-limits), 2026-11-02

## Questions

### Is my content backed up?

Yes: it lives in the PostgreSQL database, which is backed up every day and can go back to a precise moment.

### Where do my images and files go?

Directus keeps them on its disk (source 2), which starts from scratch on every deployment: keep your media elsewhere, or import them again after an update.

### Can my site read the Directus API?

Yes, Directus stays public, and its own sign-in protects the back office.

### Where is my Directus hosted?

In France, by Nextmap, a French company.
