Using Cursor and Claude Code for Roblox game creation with AI (MCP workflow)
How to pair Cursor, Claude Code, Windsurf, or Codex with penui MCP and Roblox Studio MCP to create Roblox game UI and Luau ScreenGuis from natural language.
Most AI coding workflows for Roblox break down at the UI layer. Your agent can write DataStore modules, combat hitboxes, and RemoteEvent handlers in Luau, yet the moment you ask it to build a shop or inventory in StarterGui, it invents coordinates from scratch and outputs flat colored rectangles.
The fix is not a better prompt. It is running two specialized Model Context Protocol servers side-by-side inside the agent you already use—penui MCP for Figma-accurate UI components and Luau compilation, and Roblox Studio MCP for uploading textures and executing Luau directly inside your open place file.
Why run two MCP servers side-by-side
Each server owns half of the pipeline, and neither replaces the coding agent:
- penui MCP (
penui-mcp): A local stdio (or bearer-protected Streamable HTTP) server exposing 33 MCP tools, 6 MCP resources, and thebuild-roblox-uiprompt. It gives the agent visual contact sheets, pre-split layered UI units, free local layout previews, and deterministicScreenGuicompilation. - Roblox Studio MCP: The bridge plugin running inside Roblox Studio. It exposes
upload_imageto import staged PNGs under your Studio session andexecute_luauto instantiate the compiledScreenGuiinsideStarterGui.
Because MCP servers cannot call one another directly, your AI client—Cursor, Claude Code, Windsurf, VS Code Copilot, Zed, Gemini CLI, OpenAI Codex, or Antigravity—acts as the coordinator between them.
1. Register penui MCP in your AI client
Requires Node.js 20 or newer. You can inspect supported clients and register penui with one command, or add the stdio entry manually:
# Inspect supported clients and configure Cursor, Claude Code, Windsurf, or Codex
npx -y penui-mcp setup --list
npx -y penui-mcp setup --client cursor
npx -y penui-mcp setup --client claude-code
On first run, setup copies the free Starter library (4 packs including 800+ CC0 icons) into ~/.penui/library. If you have a PENUI_API_KEY (rk_...), pass --key "$PENUI_API_KEY" or set it in your environment so setup stores it with 0600 permissions.
Client config formats at a glance
If you prefer manual configuration, note that each client uses slightly different keys:
- Cursor (
~/.cursor/mcp.json): Requires"type": "stdio"undermcpServers.penui. Using the absolute Node binary path (written automatically bysetup) prevents GUI launch failures when Cursor does not inherit nvm, volta, or fnm shell paths. - Claude Code (
~/.claude.jsonor repo.mcp.json): StandardmcpServers.penuistdio entry with"command": "npx"and"args": ["-y", "penui-mcp"]. - Windsurf (
~/.codeium/windsurf/mcp_config.json): StandardmcpServers.penuistdio block. - OpenAI Codex (
~/.codex/config.toml): TOML table[mcp_servers.penui]withstartup_timeout_sec = 30.
{
"mcpServers": {
"penui": {
"type": "stdio",
"command": "npx",
"args": ["-y", "penui-mcp"]
}
}
}
If your client requires a URL instead of stdio, start Streamable HTTP mode locally with a 16+ character token:
PENUI_MCP_HTTP_TOKEN="your-random-16-char-token" node mcp/server.mjs --http
# Listens strictly on 127.0.0.1:4174 (/mcp, /sse, /health)
2. How the agent discovers the library
Once both MCP servers are connected and Studio is open with a place loaded, give the agent a concrete screen request—for example: "Build a 1280x720 simulator coin shop with 4 item cards, currency counter, and close button in StarterGui."
A well-behaved agent follows a deterministic sequence rather than guessing names:
- Read entry resources: It inspects
penui://index(pack counts and intent-based tool routing),penui://themes(14 Roblox game genres mapped to packs and required screens), andget_studio_workflowonce for the upload/execution contract. - Pick a direction: It calls
match_themewith your prompt or inspectsdecide_screento get a role tree, scale, texture bans, and candidate units from one consistent base pack. - Inspect contact sheets instead of blind IDs: Calling
search_unitswithcontact_sheet: truereturns one numbered grid PNG of up to 24 units, letting vision-capable models verify shapes, proportions, and surface textures in a single round trip. - Check layers before composing: Calling
get_unitwithparts_images: truereveals individual layer PNGs so the agent can keep, reorder, or omit a background stud texture or glow viaitems[].layers.
3. Preview for free before touching Studio
Calling preview_units is free and accepts the exact same payload as compose_units (supporting layout: "manual" | "row" | "column" | "zones", custom texts overrides, and scale). It returns:
- A composite PNG rendered with your custom button and card copy drawn in.
- An overlap critique and sight-line report flagging clipped edges or crowded labels.
- An inspectable HTML layout file.
Iterating on preview_units takes a second or two and catches 90% of alignment and copy-length mistakes before any asset is uploaded or any metered Luau call is spent.
4. Upload art (or build natively) and run Luau in Studio
When the preview looks right, the agent chooses between two output paths:
- Zero-upload native fallback: For buttons, panels, headers, tiles, bars, and inputs,
compose_unitsorcompose_screenwith native mode synthesizesFrame+UICorner+UIGradient+UIStroke+TextLabelinstances directly from the Figma palette and corner radii. No image upload is needed. - Pixel-exact artwork via Studio bridge: When using designer PNGs, the agent calls
upload_unit_assets(bypackor specificids). penui spins up a temporary localhost-only HTTP stage (http://127.0.0.1:<port>/<token>/...) and returnsimagePathsbatches. The agent passes those URLs to Roblox Studio MCP'supload_image, then feeds the returnedrbxassetid://map back into penui'sregister_uploaded_assets, which caches them inlibrary/roblox-ids.json.
Finally, the agent calls compose_units to generate one self-contained ScreenGui Luau script (complete with AutoScale LocalScript, UIScale, and a validation header checking for orphan, off-canvas, clipped, duplicate-art, or mixed-packs issues) and sends it to Studio via execute_luau.
Frequently asked questions
Can Cursor or Claude Code run penui MCP and Roblox Studio MCP at the same time?
Yes. Both servers run concurrently in your MCP client config (Cursor mcp.json, Claude Code ~/.claude.json or .mcp.json, Windsurf mcp_config.json, or Codex config.toml). The AI agent reads units and compiles Luau from penui, stages PNGs for Studio upload_image, registers the returned rbxassetids, and runs the final script with execute_luau.
Do I need a Roblox Open Cloud API key to upload penui UI art?
No. While Open Cloud (ROBLOX_API_KEY) is supported, the default Studio bridge uses upload_unit_assets to serve PNGs on a temporary 127.0.0.1 URL so Roblox Studio MCP upload_image imports them using your already logged-in Studio session.
Which penui MCP calls are free while iterating in Cursor or Claude Code?
Discovery (ping, list_packs, match_theme), visual browsing (search_units, get_unit, suggest_combos, suggest_icons), layout verification (preview_units), spatial reconnection, design tokens, and asset upload/registration are all free. Only Luau compilation (compose_units, compose_screen, get_luau) is metered.
Why does penui setup write an absolute Node path in Cursor?
GUI editors like Cursor on macOS, Windows, and Linux often launch without your shell PATH (nvm, volta, asdf, or Homebrew). Writing the resolved Node binary path prevents spawn ENOENT errors when Cursor starts the stdio server.