Run a Luau Script with the Whole Tool Surface (mcp.*) + Persistent VM
scriptExecute Luau in the active Roblox client with inline access to all MCP tools via an mcp table, enabling one round-trip instead of dozens.
Instructions
Run a Luau program in the active Roblox client that can ALSO call any other tool inline through a live mcp table, and use the results in the same script — one call instead of dozens of round-trips. Inside the script: game, workspace, and all in-game globals are available, PLUS mcp.<tool>(args) invokes any of this server's tools and RETURNS its data. Tool names are camelCase of the tool id (e.g. mcp.getPlayers(), mcp.searchInstances({ className = 'RemoteEvent' }), mcp.findFunctionsByName({ name = 'buy' })), or use mcp.call('kebab-tool-name', { ... }). For N independent calls use mcp.all({ players = { 'get-players' }, remotes = { 'search-instances', { className = 'RemoteEvent' } } }) — runs them all in parallel server-side with a single round-trip and returns a table keyed identically. print/warn are captured and returned as output (and still stream to the dashboard Output console). By default the script runs in a PERSISTENT VM: globals and functions you define survive across script calls (a REPL-like session) — set persistent:false for a clean one-shot, or call vm-reset to wipe the VM. Returns { result = <return value>, output = [lines] } or { error, output }. mcp.script is disabled (no recursion). Signature: { source: string, client: string?, agent: string?, persistent: boolean?, timeoutMs: number?, rpcBudget: number?, threadContext: number? }. Phase: orchestrate; cost=medium; idempotency=contextual-write. Requires: active-client, explicit-mutation-approval, validated-source. Produces: structured-result. Verify with: assert-state. Safety: MUTATING; writes live game/client state. On failure: inspect tool-schema for exact fields, defaults, constraints, and an invocation example.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent | No | Optional. A stable label for WHICH agent is calling when several share this MCP session (e.g. 'researcher'). Gives that agent its own fair scheduling lane, its own persistent VM on each game, and its own queue budget, so co-tenant agents don't starve or clobber each other. | |
| client | No | Optional. Run on a specific connected client — its clientId OR username — for THIS call only, overriding your session's select-client binding WITHOUT changing it. Lets multiple agents drive different games at the same time; omit to use your session's selected client. | |
| source | Yes | The Luau script to run. Has `game`/`workspace`/all in-game globals, plus `mcp.<tool>(args)` to call any tool and use its returned data inline. `print`/`warn` are captured. `return <value>` to hand a value back. | |
| rpcBudget | No | Max number of `mcp.*` tool calls this script can make through the bridge (default 500). Further calls reject with BUDGET_EXCEEDED so a runaway loop can't saturate the connection. | |
| timeoutMs | No | Overall timeout for the whole script including nested tool calls (default 120000). | |
| persistent | No | Run in the persistent VM so defined globals/functions survive across calls (default true). false = a fresh, isolated environment each run. | |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |