Blog / MCP Workflow 5 min read

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:

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:

{
  "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:

  1. 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), and get_studio_workflow once for the upload/execution contract.
  2. Pick a direction: It calls match_theme with your prompt or inspects decide_screen to get a role tree, scale, texture bans, and candidate units from one consistent base pack.
  3. Inspect contact sheets instead of blind IDs: Calling search_units with contact_sheet: true returns one numbered grid PNG of up to 24 units, letting vision-capable models verify shapes, proportions, and surface textures in a single round trip.
  4. Check layers before composing: Calling get_unit with parts_images: true reveals individual layer PNGs so the agent can keep, reorder, or omit a background stud texture or glow via items[].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:

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:

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.

Install the MCP server · All posts · RSS feed