Documentation
Real-time rooms, players and saves, leaderboards, player-created content and authoritative server logic. The snippets below use a placeholder key; sign up and the in-app docs wire every snippet to your real key. Questions about limits and cost are in the FAQ and on the pricing page.
What Multiplayer Agent is, what it's for, and the services it gives you, then your keys and the one script tag that loads the SDK. Every snippet on the other tabs assumes you've done this last part first.
Multiplayer Agent: SDK reference
⚠️ This is the public reference: the key below is a PLACEHOLDER. Sign up and create a game to get your own.
Everything below is wired to ONE game: (unnamed game) (pk_live_create_a_game_first). A studio holds many games and each has its own key: confirm that is the game you are building before you copy anything, because the publishable key routes players, saved progress and leaderboards. Ship the wrong one and nothing errors: the room works and your players quietly accumulate in another game.
The publishable key (pk_…) is safe to ship in client HTML; it routes the tenant and resolves player scope. Never put a secret key (sk_…) in a client.
Your values:
- game: (unnamed: name it with set_game_name)
- publishableKey:
pk_live_create_a_game_first - realtime endpoint (wsEndpoint):
wss://live.multiplayeragent.com - control-plane (apiUrl):
https://api.multiplayeragent.com - SDK bundle (sdkUrl):
https://cdn.multiplayeragent.com/sdk/mp.global.js
What Multiplayer Agent is
Multiplayer Agent is a hosted backend for browser games. You write the game the way you already would: HTML, JS, canvas, or any web engine, and call this SDK for the parts that need a server: the other players, saved progress, scores, purchases. There is no server to run, no netcode to write, no database to model, and no schema to declare before you start.
What one key gets you. The publishable key above routes every service below, and each has its own section further down:
- Realtime rooms: live shared state between the players in a room, plus reliable ordered events for shots, hits, pickups and abilities. A room is just a name, and it auto-creates the first time somebody joins it.
- Player identity: anonymous-first, survives a reload, claimable into a real username/password login, and linkable to a portal account (Y8, Poki, CrazyGames, Google) so the same player carries across devices.
- Player datastore: a JSON document per player for saves, stats, inventory and loot.
- Leaderboards: named boards with max/inc/set submits, top-N, each player's rank, and the board's total size for "rank 7 of 412".
- Player-created content: a shared per-game library players publish levels, ships, decks or ghosts into, with share-code deep links, voting, reporting and an owner moderation queue.
- Authoritative server logic: deploy JS that runs the room on the server, so clients send inputs instead of state and cannot cheat the rules, the saves, or the scores. Versioned, with logs and rollback.
- Monetization: one-time Stripe purchases granting server-verified entitlements a client can read but can't fake, plus bring-your-own ads (you keep 100% of the ad revenue).
- Analytics, errors & bug reports: anonymous first-party sessions on every join, custom events, auto-captured client errors, and in-game player bug reports, all on the owner's dashboard. No third-party trackers, ever.
Two ways to build. Drop the <script> tag below into a page and call the SDK yourself, or point an AI agent at the MCP server and let it create the game, define rooms, deploy server logic and write the client code for you. Both land on the same backend; the agent path just skips the reading.
What it's for. Turn-based, casual, co-op, party, puzzle, and arena/.io games and casual shooters, if you apply the patterns in "Building real-time games well" below. Because a game is just a room name, extra modes and levels are free.
What it isn't for. Competitive twitch action (FPS, racing): the transport is WebSocket: reliable and ordered, but not UDP, with no rollback or lag compensation. Note also that room state replicates to every client in the room, so hidden-information games (hidden hands, fog of war) must keep the secret inside authoritative server logic and reveal it with emitTo, rather than putting it in room state and hoping clients don't look.
Load the SDK
<script src="https://cdn.multiplayeragent.com/sdk/mp.global.js"></script> <!-- exposes a global `MP` -->
(ESM: import * as MP from "@mp/sdk".)