> For the complete documentation index, see [llms.txt](https://docs.edgegap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.edgegap.com/docs/sample-projects/web-games/codex-slime-sumo.md).

# Codex Slime Sumo

Make a game built with OpenAI Codex multiplayer with Edgegap: the Edgegap plugin and MCP server let Codex add an authoritative server, Find Match, the server image and a test deployment.

Learn how to take a browser game made with [OpenAI Codex](https://developers.openai.com/codex) online on Edgegap, with Codex doing the work.

![Codex Slime Sumo, running online matches on Edgegap](https://raw.githubusercontent.com/edgegap/netcode-sample-codex-slime-sumo/main/docs/images/card.jpg)

Slime Sumo is an arena game for 4 slimes on a round platform that slowly shrinks: bump the others off, dash on Space, last slime standing wins the round, first to 3 rounds wins the match. Codex wrote the whole game, solo against 3 bots, with OpenAI's Game Studio plugin (Phaser and Vite). Then, with the Edgegap plugin and MCP server, Codex made it online multiplayer from one more prompt.

* **Codex**: used while you build the game, and to add the server, Find Match, the image and a test deployment.
* **Edgegap**: used while people play, for one dedicated server per match, near its players, and matchmaking.

This sample shows:

* **Two prompts**: one for the solo game, one to go online. The repository keeps both, word for word, in `PROMPTS.md`, and the tag `before` holds the game as Codex first wrote it.
* **One rules module**: Codex moved the game rules into `src/rules.js`, which the page and the Node.js server both import, so the server owns the outcome and solo play still runs offline.
* **Codex using Edgegap tools**: it checked the Dockerfile with `edgegap_validate_server_config`, pushed the image, created the application and its version, deployed a test server tagged `agent-test`, joined it from two browser tabs and stopped it.
* **Find match**: 2 to 4 players per match with the [Edgegap JavaScript SDK](https://www.npmjs.com/package/@edgegap/sdk), with bots in the empty seats.

{% hint style="info" %}
See the [sample repository](https://github.com/edgegap/netcode-sample-codex-slime-sumo) for the game, the game server, the matchmaker config, the tests and every prompt.
{% endhint %}

## ✔️ Preparation

Before we start, you will need:

* [Codex Slime Sumo sample](https://github.com/edgegap/netcode-sample-codex-slime-sumo), or your own game made with Codex.
* [Codex](https://developers.openai.com/codex) (CLI, IDE extension or the ChatGPT desktop app), signed in with ChatGPT.
* [Node.js](https://nodejs.org/) 22 or newer.
* [Docker](https://docs.docker.com/get-docker/) logged in to your Edgegap Container Registry, or a GitHub repository so GitHub Actions can build the server image.
* An [Edgegap account](https://app.edgegap.com/auth/register). No credit card required.

<details>

<summary><a href="https://www.docker.com/products/docker-desktop/">Install Docker Desktop (or Docker CLI)</a></summary>

* [Install Docker Desktop from the official source](https://www.docker.com/products/docker-desktop/) (no account required).
* Restart your computer after completing the installation.

</details>

☑️ Try the game locally first:

{% code collapsedlinecount="10" %}

```bash
npm install
npm run dev
```

{% endcode %}

Open `http://localhost:5173` and click **Play Solo** for a solo match against 3 bots.

## 🤖 Build the Game with Codex

### 1. Add the Plugins

☑️ Add OpenAI's **Game Studio** plugin from the Plugins Directory, then the Edgegap plugin:

{% code overflow="wrap" collapsedlinecount="10" %}

```bash
codex plugin marketplace add edgegap/llm-agent-skills
codex plugin add edgegap@edgegap
codex mcp login edgegap
```

{% endcode %}

The Edgegap plugin installs the Edgegap skills and connects the hosted [Edgegap MCP server](https://github.com/edgegap/llm-mcp-server). `codex mcp login edgegap` opens the Edgegap sign-in in your browser: pick your organization and approve access. No API token is needed.

☑️ Run `codex mcp list`: `edgegap` shows **OAuth** auth.

✅ You may now proceed to the next step.

### 2. Ask for the Solo Game

☑️ Start Codex in an empty folder. Slime Sumo came from this prompt:

{% code overflow="wrap" collapsedlinecount="10" %}

```
Use $game-studio. Make a small browser game called Slime Sumo with Phaser: a top-down arena where 4 slimes try to bump each other off a round platform that slowly shrinks. The player controls one slime with WASD or the arrow keys, plus a dash on Space; the other three are bots. Last slime on the platform wins the round; first to 3 rounds wins the match. Keep it simple: shapes and colors, no external assets. Use Vite, and make sure it runs with npm install && npm run dev.
```

{% endcode %}

☑️ Play a few rounds before going online. Playtest notes go into the next prompt: here, rounds never ended when the timer reached 00:00 with two or more slimes left.

✅ You may now proceed to the next step.

### 3. Ask Codex to Go Online

☑️ Find your [Container Registry](https://docs.edgegap.com/learn/advanced-features/edgegap-container-registry.md) project name and credentials.

☑️ Sign in to Edgegap's Container Registry with Docker, using your registry project name, username and token:

{% tabs %}
{% tab title="Bash (Linux)" %}

```bash
project='<REGISTRY_PROJECT>';
username='robot$<REGISTRY_ORGANIZATION_ID>+client-push';
token='<REGISTRY_TOKEN>';

echo "$token" | docker login registry.edgegap.com -u "$username" --password-stdin 2>&1
```

{% endtab %}

{% tab title="PowerShell (Windows)" %}

```powershell
$project = '<REGISTRY_PROJECT>'
$username = 'robot$<REGISTRY_ORGANIZATION_ID>+client-push'
$token = '<REGISTRY_TOKEN>'

echo "$token" | docker login registry.edgegap.com -u "$username" --password-stdin 2>&1
```

{% endtab %}
{% endtabs %}

☑️ Give Codex one prompt:

{% code overflow="wrap" collapsedlinecount="10" %}

```
Use $edgegap-vibe-coded. Make Slime Sumo online multiplayer on Edgegap: up to 4 players per match on one authoritative server, bots take the empty seats, a Find Match button that goes through Edgegap's matchmaker, and the solo mode keeps working offline. Playtest note: when the timer reaches 00:00 the round never ends if two or more slimes are still on the platform; fix that too.
Docker is already logged in to registry.edgegap.com; my registry project is <registry-project>. Build the server image, push it, create the app slime-sumo and a version for it, then deploy one test server and prove that two browser tabs can join it directly. You can deploy test servers without asking me; tag them agent-test and stop them when you're done. Don't create a matchmaker: write the matchmaker profile JSON and I'll add it to my existing matchmaker. Don't commit.
```

{% endcode %}

Codex worked for about 30 minutes without further input. It loaded the `edgegap-vibe-coded`, `edgegap-threejs` and `edgegap` skills, then:

* moved the rules into `src/rules.js` and fixed the timer (at 00:00, the slime closest to the centre wins),
* added the authoritative server: 4 seats, bots for the empty ones, a matchmaker ticket check, and a self-stop when the match ends or empties,
* added **Find Match** and a `?server=` link to join one server directly,
* tested two browser tabs against a local server, and the image on a random external port,
* validated the Dockerfile, pushed the image, created the application and a version with port `7777`, protocol **WS**, **TLS Upgrade** on,
* deployed a test server, joined it from two browser tabs over `wss://`, and stopped it.

{% hint style="warning" %}
On Windows, the Codex CLI's sandbox may only allow reading files. Run the online step in the ChatGPT desktop app, in WSL, or start `codex` with `--dangerously-bypass-approvals-and-sandbox` in the game's folder only.
{% endhint %}

☑️ Read the changes before you commit them. In this sample, the matchmaker Auth Token moved to a git-ignored `src/config.local.js`, and the profile got the same sizes as the other games on the matchmaker.

✅ You may now proceed to the next step.

## 🎮 Play Online

### 4. Join One Server Directly

☑️ Deploy your version from the dashboard (**Deployments**, **Create Deployment**) and copy `wss://<fqdn>:<external port>`.

{% hint style="warning" %}
**TLS Upgrade** lets browsers on `https` pages connect to `wss://<id>.pr.edgegap.net:<port>`. Edgegap terminates TLS and forwards plain WebSocket traffic to port `7777`. Connect with the host name, not the IP, so the certificate matches.
{% endhint %}

☑️ Open `http://localhost:5173/?server=wss://<fqdn>:<port>` in two browser tabs. Both join the same match; bots take the other seats.

🙌 Congratulations on your first Deployment on Edgegap!

✅ You may now proceed to the next step.

### 5. Find Match

☑️ Add the profile from [`matchmaker/slime-sumo.json`](https://github.com/edgegap/netcode-sample-codex-slime-sumo/blob/main/matchmaker/slime-sumo.json) to your matchmaker, with your own application version and your page's origin in `allowed_cors_origins`.

☑️ Create `src/config.local.js` (git-ignored) with your matchmaker's **API URL** and **Auth Token**:

{% code collapsedlinecount="10" %}

```js
export default { url: 'https://<id>.edgegap.net', token: '<matchmaker auth token>' };
```

{% endcode %}

☑️ Click **Find Match** in two browser tabs. Verified on Edgegap: both tabs were matched onto one server in 16 seconds, and the server stopped itself about 30 seconds after both tabs left.

{% hint style="info" %}
The matchmaker Auth Token is a client token: it can only ask for matches. Never put your Edgegap API token in the page, the repository or the image.
{% endhint %}

## 🧭 Keep Codex on Track

☑️ Copy the Edgegap section of [`AGENTS.md`](https://github.com/edgegap/llm-agent-skills/blob/main/skills/edgegap/assets/AGENTS.md) into your repository's `AGENTS.md`: authoritative server, the token never in the repository, timestamped image tags, and asking before deploying.

## 🧹 Clean Up

Each server stops itself when its match ends or empties. When you're done, stop the matchmaker, and delete the application version and its image if you no longer need them.
