Skip to main content
Glama

Deploy authoritative server logic

deploy_room_logic

Deploy server-side game logic (JS source) for a room so it runs AUTHORITATIVELY: clients send inputs and the server computes state on a tick (anti-cheat by construction). Define handlers as functions over a global state (RoomStateView shape): onJoin(id), onLeave(id), onInput(id, input), onEvent(id, type, data), onTick(dt); emit(type,data)/emitTo(id,type,data) send events to clients. For TRUSTWORTHY persistence the client can't fake, call saveData(id, patch)/loadData(id) (the player's server-only save) and submitScore(id, board, score, mode), the server decides the values (the client passes its identity via MP.join({…, player})). Each deploy returns a version (roll back with rollback_room_logic; read runtime errors with get_room_logs). Limits: code <= 256KB, tickRate 1-60. The code runs in a locked-down isolate: handlers must be SYNCHRONOUS (no async/await/promises/timers), there is no network or require, console.* is a no-op, and state must stay JSON-serializable (no Map/Set/class instances). Call get_sdk_reference for the full contract.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "roomName": "<roomName>"
    },
    "name": "deploy_room_logic"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeNoJS source defining onJoin/onLeave/onInput/onEvent/onTick over a global `state`. Or, for a long file, pass uploadId instead.
gameNoWhich game to act on: its publishable key (pk_…) or its exact name. Defaults to the x-mp-game header, then your primary game.
roomNameYesThe room name to make authoritative.
tickRateNoServer ticks per second (default 20).
uploadIdNoInstead of code: the uploadId of a .js file you created with create_upload (for this game) and PUT with curl. For logic too long to send inline.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond annotations, it discloses the runtime contract: synchronous handlers only, no network or require, console no-op, JSON-serializable state, 256KB code limit, tickRate 1-60, and that each deploy returns a version. These are critical behavioral traits for an agent invoking a code-deployment mutation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

It is front-loaded with the core action and then organized into runtime contract and limits. It is dense and long, but nearly every sentence carries operational information needed for correct invocation; it could be tightened slightly without losing meaning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex mutation tool with no output schema, the description covers what deployment does, what the code must look like, runtime restrictions, limits, return/version behavior, and where to find more detail. Nothing an agent needs to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the structured fields already document each parameter. The description still adds useful semantic depth by explaining the handler shape and the persistence/emit APIs available inside code, though it does not add much beyond the schema for game/roomName/uploadId.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The first sentence names a specific verb and resource ('Deploy server-side game logic ... for a room') and immediately scopes it as authoritative server execution. An agent can distinguish this from rollback_room_logic, get_room_logs, and get_sdk_reference because those siblings are named later with distinct roles.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description makes the use case clear (authoritative room logic, anti-cheat, trustworthy persistence) and points to rollback_room_logic for rollback, get_room_logs for runtime errors, and get_sdk_reference for the full contract. It does not explicitly state when not to use this tool, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.