System Architecture
RbxGenie consists of three main components that work together to enable AI-driven Roblox Studio automation:MCP Server
Model Context Protocol adapter for AI assistants
Node.js Daemon
HTTP server with event-driven polling bridge
Studio Plugin
Roblox Lua plugin with tool executors
Data Flow
The complete request-response cycle follows this path:AI Tool Call
AI assistant (Claude/Cursor) calls a tool like
get_file_tree or set_property through the MCP protocolMCP Translation
MCP server (
mcp.ts) receives the tool call, validates arguments with Zod schemas, and forwards to the daemon via HTTP POST to http://127.0.0.1:7766/tool/{name}Command Queueing
HTTP daemon (
server.ts) receives the request, generates a UUID, and enqueues the command in the bridge (bridge.ts) with a 120-second timeoutLong Polling
Studio plugin polls
GET /poll endpoint (15-second long poll). When a command is available, it’s dequeued and returned to the pluginTool Execution
Plugin’s
Executor.lua dispatches the tool to the appropriate tool module (InstanceTools, PropertyTools, etc.) and executes it against the Roblox DataModelComponent Communication
HTTP Endpoints
The daemon exposes these endpoints onhttp://127.0.0.1:7766:
| Endpoint | Method | Purpose | Used By |
|---|---|---|---|
/health | GET | Health check and connection status | Plugin (connection loop) |
/tool/:name | POST | Submit a tool execution request | MCP server |
/poll | GET | Long-poll for pending commands (15s timeout) | Plugin (Bridge.lua) |
/result | POST | Submit command result or error | Plugin (Bridge.lua) |
Event-Driven Bridge
The bridge (bridge.ts:1) maintains an in-memory queue of pending commands:
The bridge uses an EventEmitter pattern with a
"enqueued" event to wake up long-polling requests immediately when a new command arrives, avoiding the full 15-second wait.Timeout Handling
RbxGenie implements a multi-layer timeout strategy:- Command Timeout
- Long Poll Timeout
- MCP Proxy Timeout
120 seconds — Commands timeout if not completed within 2 minutesLocation:
bridge.ts:15Undo/Redo Support
Write operations (non-read-only tools) are automatically wrapped in Roblox ChangeHistoryService recordings:All property changes, object creation, script edits, and other mutations can be undone with Ctrl+Z in Roblox Studio.
Error Handling
Errors are propagated through the entire chain:- Tool execution error → Lua
pcallcatches it → Posted to/resultwitherrorfield - Path resolution error → Returned as structured error from
PathResolver.resolve - HTTP error → Daemon returns 500 with
ok: falseand error message - Timeout → Bridge rejects promise with
{ error, timeout: true, timeoutMs } - MCP error → Returned as
{ isError: true }response to AI
Performance Characteristics
Request Latency
Typical: 50-200ms for simple queries
Complex operations: 500ms-2s
Worst case: 120s (timeout)
Complex operations: 500ms-2s
Worst case: 120s (timeout)
Concurrency
Single-threaded command execution
One command at a time in Studio
Queue size: Unlimited (memory-bound)
One command at a time in Studio
Queue size: Unlimited (memory-bound)
Security Model
- Local-only: Daemon binds to
127.0.0.1only (server.ts:108) - No authentication: Assumes single-user local development environment
- Studio HttpService: Plugin requires
HttpServiceenabled in Studio settings - Execution sandbox: Lua code runs in Studio’s edit-mode environment with full API access
The
execute_luau tool can run arbitrary Lua code in Roblox Studio. Only use RbxGenie in trusted AI sessions. Do not expose the daemon to network access.Next Steps
Node.js Daemon
Learn about the HTTP server and bridge implementation
Studio Plugin
Explore the Lua plugin architecture and tool executors
MCP Server
Understand the Model Context Protocol adapter