spawn_exec
Run read-only JavaScript snippets to query live game objects and inspect their state in the active room. Requires a live player connection.
Instructions
Run a read-only JavaScript snippet against the live room (e.g. query objects, read an object's state). Pushing is the only write path. Needs a LIVE ROOM — rooms exist only while a player is connected, so open spawn_play_open first or you get a 5xx. api.sql is NOT available here at all (the endpoint is read-only server-side and refuses SQL outright, even SELECT) — there is no way to read the game database through this server.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | JS to eval in the live room, e.g. return api.query({}).slice(0,50).map(o => ({id:o.id, pos:o.feetPosition, tags:o.tags})) | |
| projectDir | No | Absolute path to the Spawn game project (game.json / .env). Defaults to SPAWN_PROJECT_DIR or the MCP process cwd. |