Make a multiplayer game with OpenAI Codex
Updated 2026-11-23
Short answer: run Codex in your web game's folder (the CLI or the IDE extension) and give it Joinable's prompt. Codex reads getjoinable.com/AGENTS.md, picks the pattern for your genre, adds an async script tag and a few hooks, and runs npx getjoinable test to play a round in two real browsers. No server code, no account and no key while the game runs on localhost. To give Codex Joinable's tools, add the MCP server to ~/.codex/config.toml.
1. Give Codex the prompt
Start Codex from the game's folder (codex in a terminal, or the extension in your editor with the folder open) and paste:
Make this web game multiplayer using Joinable. Read
https://getjoinable.com/AGENTS.md first and follow it exactly: it says how
to pick the right pattern for this game's genre, what to change, and how to test
with two browser tabs. Start with the smallest change that works (usually one
script tag), test it with two tabs, and only go further if the doc's checks fail
for this game. Don't write any server code: Joinable's hosted relay does all of
that. No key is needed on localhost. If the doc's self-test applies (full rounds),
run it with `npx getjoinable test <the game's local URL>` until it passes. When
you're done, tell me which pattern you used, what you changed, and anything that
doesn't sync.
Codex needs network access for two things: reading the kit, and the self-test, which connects to Joinable's relay and installs the getjoinable package with npx. Depending on your sandbox and approval settings, Codex asks before it uses the network or runs commands; allow them for this task. If it can't reach the web at all, add the MCP server below, or save https://getjoinable.com/AGENTS.md into the repository and tell Codex to read that file.
You can also put the kit's URL in the project's own AGENTS.md, which Codex reads at the start of every session, so later tasks keep following it:
Multiplayer uses Joinable. Before changing anything multiplayer, read
https://getjoinable.com/AGENTS.md and follow it. Never write server code.
2. Optional: add the MCP server
In ~/.codex/config.toml (the CLI and the IDE extension share it):
[mcp_servers.joinable]
command = "npx"
args = ["-y", "getjoinable", "mcp"]
Or from the terminal: codex mcp add joinable -- npx -y getjoinable mcp. That's the local server, with the self-test. The remote server needs nothing installed and has every tool except the self-test:
[mcp_servers.joinable]
url = "https://getjoinable.com/mcp"
The tools: joinable_kit, joinable_choose_pattern, joinable_snippet, joinable_get_started, joinable_desyncs, and locally joinable_selftest. The package is getjoinable, one word: never npx joinable, which is someone else's package.
3. What Codex changes
Codex should tell you the pattern it used. What to expect in the diff:
- Full rounds (racers, anything with a score or a time): an
asyncscript tag; oneJoinable.game({...})call queued onwindow.JoinableQwithstart,go,local,remote(race only) andstop; andwindow.Joinable?.finish({ time })orfinish({ score })where the player finishes. Level or course generation switches to the round's sharedseed. - Shared worlds (board, card, puzzle, builder):
data-sync="game"on the tag, or oneJoinable.sync(state)call. Entities in arrays getids. - Avatars (platformers, party games): a map of players, the host simulating, everyone sending inputs.
- RTS and strategy: the
lockstepprofile, when the simulation can be deterministic.
No new server, no WebSocket code, no lobby screen: Joinable draws the invite sheet, waiting room, countdown, standings, podium and rematch. Single-player keeps working if Joinable doesn't load.
4. Test it
For full rounds:
npx getjoinable test http://localhost:5173/
Two headless browsers play a round in one room and the test checks the seed, both players seeing each other, one result on both and a rematch, with a fix for each failure. Options: --players 4 (up to 8 on localhost), --round 90, --channel chrome for heavy 3D. If Playwright's Chromium is missing, run npx playwright-core install chromium first. Each run sends an anonymous usage ping (command, pass or fail, version); JOINABLE_TELEMETRY=0 turns it off.
Then play one round yourself in two browser windows side by side, and once on a phone and a laptop on different networks. Shared-world games are checked by hand in two windows: the same world in both, actions show up in both, and closing the host window leaves the other playing.
5. Go live
- Get a free key at getjoinable.com/app and add your game.
- Add the game's real address to its sites.
- Have Codex add
data-key="pk_…"to the tag. It's a public key, not a secret.
On Sandbox (free), a live site gets 100 player-hours a month in rooms of 4. Starter: $9.99 a month, 3,000 player-hours, rooms of 8. Pricing.
Troubleshooting
- Codex couldn't fetch AGENTS.md: network access is off in its sandbox. Allow it, use the MCP server, or save the file into the repository.
npx getjoinable testfails to download or connect: same cause; the test needs npm andrelay.getjoinable.com.- "Offline: key not allowed here": the page's address isn't on the game's sites.
- Codex wrote a server: ask it to remove it and follow the kit, which forbids server code.
Where it stops working
Web games only, including engines that export to the web; not native desktop, console or mobile builds. No rollback for fighting games or trusted server for competitive shooters yet. Players report their own scores, so keep prizes out of it. More in the general guide.
FAQ
Can OpenAI Codex make my game multiplayer?
Yes, for web games. Give Codex Joinable's prompt in the game's folder: it reads the kit, adds an async script tag and the hooks for your genre, and runs a two-browser self-test. No server code is involved.
How do I add Joinable's MCP server to Codex?
Add a [mcp_servers.joinable] table to ~/.codex/config.toml with command = "npx" and args = ["-y", "getjoinable", "mcp"], or run codex mcp add joinable -- npx -y getjoinable mcp. For the remote server, use url = "https://getjoinable.com/mcp".
Does it work in Codex's sandbox?
The edits do. Reading the kit and running the self-test need network access, so allow it for this task, or give Codex the kit through the MCP server or a saved copy of AGENTS.md.
Is it free?
Yes while you build: no key on localhost, rooms of up to 8. A real site needs a free key, and the free plan includes 100 live player-hours a month.