Skip to content

Host a Discord bot 24/7 with your AI, over MCP (2026)

Does your bot work on your computer? Connected to while over MCP, your AI keeps it running 24/7, and the bot restarts on its own if it stops.

By Aloïs Oddon, co-founder of Nextmap. Facts checked on November 19, 2026.

View as Markdown

Host a Discord bot 24/7 with your AI, over MCP: Discord bot hosting in France, always on, with no server to manage, put in production by Claude Code, Cursor or Codex

The short version. Over MCP, your AI deploys your Discord bot with while: it runs 24/7, with no server to manage, and its token stays secret. What matters, like deleting a database, waits for a person’s approval.

Prerequisites

  • A Discord bot, in Node.js or Python.
  • An AI that works in a terminal: Claude Code, Codex, Cursor or Gemini CLI.

Step 1: Give your AI this message

Open your AI in your bot’s folder, and paste this message into it:

The message to give your AI
Connect to while with my account (while.sh/agents), then put my app on while.

Your AI 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: Check that your bot is connected

Your AI reads the bot’s logs in while, and tells you when it’s connected to Discord.

What your AI does

It writes while.yaml next to your bot:

while.yaml
apiVersion: while/v1
project: mon-bot
services:
  - name: bot
    type: worker
    command: [node, bot.js]
network:
  egress: all

Your bot runs continuously, with no public address. The last two lines open the internet to it, so it can reach Discord.

Host a Discord bot 24/7 with no sleep: an always-on Discord bot answering day and night, its token kept out of the AI's reach, on while in France
Your bot runs day and night, and its token stays in while.

Keep the bot’s token secret

You, to your AI: Connect the bot with its Discord token.

You enter the token in while: your bot receives it, and your AI never sees it.

Add a command to the bot

You, to your AI: Add the /planning command to the bot.

Your AI changes the code and deploys the bot again in a few seconds, without ever running it twice.

Post at a set time

You, to your AI: Post the schedule every Monday at 9 am.

Your AI declares a scheduled job, with the same code and the same token.

Add a database

You, to your AI: Add a PostgreSQL database.

Your AI declares the database in while.yaml, and its address reaches your code in DATABASE_URL. The database is backed up every day, with a way back to a precise moment over 14 days.

Go back to the previous version

You, to your AI: Go back to the previous version of the bot.

The previous version of the bot takes over in a few seconds, without ever running twice. Then your AI reads what broke in while’s logs, fixes it and deploys again.

In the docs: PostgreSQL databases, Scheduled jobs, Worker, Versions and rollback and Variables and secrets.

Next steps

Sources

  1. Discord, messages (posting a message to a channel through the HTTP API), accessed November 2, 2026
  2. Discord, getting started (the bot token), accessed November 2, 2026

Questions

Does my bot answer twice during an update?

No: a new version replaces the old one without ever running twice.

Node.js or Python?

Both, or any other language with a Dockerfile.

How much does a bot cost?

A bot uses little, and you only pay for the CPU and memory it uses.

Where do my app and its data run?

In France, at Nextmap. The database is backed up every day, with a way back over 14 days, once a person approves.

Does my AI see my credentials?

No. You paste them into while, the app uses them, and your AI never sees them. Every call is logged.

Give your AI the message, and it takes care of the rest

Give this to your AI

Read while.sh/agents and help me get started with while.

Copy the message

In 3 minutes, with no sign-up, the tool has its own address. To keep it, create your account.

For a company project, write to the while team: hello@while.sh