Blog / AI UI Architecture 3 min read

Create UI with AI: why deterministic Figma-to-Luau MCP beats prompt generators

Why prompt-only AI UI builders hallucinate coordinates and produce placeholder boxes, and how pre-split layered units with 9-slice insets and editable TextLabels let agents create real UI with AI.

Most attempts to create UI with AI fall into one of two failure modes. Text-to-code generators guess coordinates and emit generic rectangles with arbitrary border radii. Text-to-image generators produce a single flattened PNG that looks appealing as a concept image, yet cannot be clicked, localized, resized across aspect ratios, or wired to live player state.

Building production game interfaces requires a third model: deterministic component assembly over MCP. Instead of asking a language model to invent artwork or geometry from weights, you give the agent a machine-readable catalog of pre-split, designer-made Figma units.

Why prompt-only AI UI generators break in real games

How deterministic Figma-to-Luau MCP works

penui extracts every screen from real .fig design files into structured, inspectable units before an AI agent ever sees them. Each unit exposes exact metadata rather than vague descriptions:

Inspecting before committing with preview_units

Deterministic generation also means cheap verification. When an agent calls preview_units, penui renders the exact composition—with your overridden button labels, card titles, and scale factor—to a PNG and HTML inspection artifact without touching Roblox Studio or spending metered generation units.

If a title wraps awkwardly or two containers touch, the agent sees the exact bounding boxes and sight-line warnings, adjusts the parameters, and calls compose_units only once the layout is verified.

Native instances when speed matters, bitmaps when art matters

Deterministic Figma tokens also power zero-upload native synthesis. For buttons, panels, headers, tiles, bars, and inputs, the compiler derives UIGradient stops, UICorner radii, and UIStroke widths directly from the Figma palette—letting you ship crisp, dependency-free UI immediately or upgrade hero elements to rbxassetid:// art without rewriting your layout tree.

Frequently asked questions

What makes a deterministic MCP UI server different from an AI UI generator?

A prompt-only generator guesses coordinates, colors, and shapes from scratch. A deterministic MCP UI server like penui serves real Figma-extracted components with exact sizes, 9-slice insets, typography bounds, and repeat offsets so the AI selects and composes proven art.

Are text labels editable when you create UI with AI in penui?

Yes. Units with text ship a text-free notext.png layer paired with a texts[] metadata array describing position, size, color, stroke, and font (Fredoka One or Montserrat). The generated Luau creates real TextLabel instances you can update at runtime.

How does penui prevent repeated shop cards from drifting out of alignment?

Repeated components store exact Figma coordinates in repeatPositions (and alsoFoundIn on units). compose_units and compose_screen build one card and clone siblings via REPEAT_OFFSETS and Clone().

Which AI clients can use penui to create UI with AI?

Any client supporting the Model Context Protocol over stdio or local Streamable HTTP, including Claude Code, Claude Desktop, Cursor, Windsurf, VS Code Copilot, OpenAI Codex, Gemini CLI, Zed, Cline, Roo Code, and Google Antigravity.

Install the MCP server · All posts · RSS feed