Skip to main content

Workflows

There are three primary ways to use the Magic Patterns MCP tools.

Prompt-based

Delegate creative work to Magic Patterns’ AI. Send a natural language prompt and let the AI generate or update code.

Code-first

Write code directly into artifacts. Create a working branch, edit files, and publish when done.

Design-system authoring

Build a reusable design system by writing components, styling, and rules directly, then publish versioned releases.

Workflow A — Prompt-based

Starting from scratch:
1. create_design(prompt, ...)         → kicks off AI generation
2. get_design_status(editorId)        → poll every 60s until isGenerating=false
With an existing design:
1. get_editor_id_from_url(url)        → resolve a Magic Patterns URL to an editorId
2. get_design_status(editorId)        → check current state before acting
3. send_prompt(editorId, prompt)      → send prompt (returns immediately)
4. get_design_status(editorId)        → poll every 60s until isGenerating=false

Workflow B — Code-first

1. create_design()                    → no prompt, creates blank design instantly
2. get_design_status(editorId)        → confirm active artifact is ready
3. create_new_artifact(artifactId, name)  → create a working branch
4. read_artifact_files(artifactId, fileNames) → read existing scaffolding
5. write_artifact_files(artifactId, files) → write one or more files at once
6. publish_artifact(artifactId, editorId)  → compile + activate

Workflow C — Design-system authoring

Author a reusable design system (components, styling, and rules) by writing files directly. You write the code here — Magic Patterns does not generate it for you. Load the design_system_authoring_guide prompt first for the full file contract.
1. list_design_systems()                      → find an existing design system ID, or…
2. create_design_system(name)                 → create a new blank design system
3. get_design_system(designSystemId)          → resolve active artifact + file list (always first)
4. read_design_system_files(designSystemId, fileNames) → read existing files before editing
5. write_design_system_files(designSystemId, files, baseArtifactId) → save files (permissive)
6. publish_design_system(designSystemId)       → publish an immutable version (strict)

Important Guidance

Collaborative editing: Magic Patterns is a collaborative editor — the user can make changes in the UI at any time. Always call get_design_status before starting new work to get the latest active artifact. Never assume state from a previous call is still current.
Polling: AI generation typically takes 2–10 minutes. Poll get_design_status no more frequently than every 60 seconds. Slow generation is normal — do not treat it as an error.
Design systems — write vs. publish: write_design_system_files is permissive — it saves your files and returns validationErrors without blocking, so you can build incrementally. publish_design_system is strict — it refuses while any validation errors remain. Clear every validationErrors entry before publishing. Design systems are also collaborative: always call get_design_system first and pass its artifactId as baseArtifactId on writes so concurrent edits are detected (a 409 means re-read and retry).

General Tools

list_design_systems
Tool
Lists the design systems available to the authenticated user. Returns both built-in presets (e.g. Base, Shadcn, MUI) and any custom design systems.

Design Tools

create_design
Tool
Creates a new Magic Patterns design. This is the starting point for both workflows.
  • With prompt: Kicks off AI generation (long-running, 2–10 minutes). Poll get_design_status every 60s.
  • Without prompt: Creates a blank design with scaffold files (App.tsx, index.tsx, index.css, tailwind.config.js). Returns immediately.
  • With templateId: Forks an existing design first, then optionally applies the prompt to the fork.
This tool requires credits when used with a prompt.
get_editor_id_from_url
Tool
Resolves a Magic Patterns URL to an editor ID.
get_design_status
Tool
Gets the current status of a design: whether AI generation is active, the active artifact ID, and available files.Always call this before starting new work on an existing design — the user may have changed state since you last checked. Also used to poll for completion after create_design (with prompt) or send_prompt.
When isGenerating=true, wait at least 60 seconds before polling again. Generation can take up to 10 minutes.
send_prompt
Tool
Sends a natural language prompt to the Magic Patterns AI for an existing design. Returns immediately with a request ID. The generation runs in the background.
Check get_design_status first to ensure isGenerating=false before sending a prompt.
Generation typically takes 2–10 minutes. Poll get_design_status every 60 seconds until isGenerating=false. This tool requires credits.
read_recent_message_history
Tool
Reads the recent chat item history for a design. Returns the last 10 items (user prompts, AI responses, artifact versions, edits). Use skip to paginate backwards.Code contents are omitted to keep the response concise — use read_artifact_files to read full file contents.
list_version_history
Tool
Lists the artifact version history for a design. Returns the most recent 20 versions.
publish_artifact
Tool
Compiles an artifact’s source files and sets it as the active artifact for the design. This is the final step in the code-first workflow.
  1. Compiles all source files (bundling for preview)
  2. Sets the artifact as active (appears in editor and preview)
  3. Adds a version entry to the design timeline

Artifact Tools

get_artifact
Tool
Gets the active artifact for a design, including its ID and list of files.Always call this (or get_design_status) to get the latest active artifact — do not rely on a previously cached artifact ID.
create_new_artifact
Tool
Creates a new artifact by cloning an existing one. The new artifact becomes the active artifact.
Call this before making file changes with write_artifact_files so the user can revert to the previous artifact if needed. Always call get_design_status or get_artifact first to get the current active artifact ID.
read_artifact_files
Tool
Reads the contents of one or more files from an artifact.
Always read files before making changes with write_artifact_files so you understand the current state.
write_artifact_files
Tool
Creates or overwrites one or more files in an artifact. If a file exists, it is replaced. If it doesn’t exist, it is created.
This only saves source files — it does not compile or publish. Call publish_artifact after finishing all file changes.

Design System Tools

These tools let an agent author a Magic Patterns design system — a reusable, versioned collection of components, styling, and rules — by writing files directly. This is distinct from the design/artifact tools above: here you write the code, rather than delegating to Magic Patterns’ AI.
Load the design_system_authoring_guide prompt before writing any files. It documents the full file/folder contract (component trios, named-export rules, index.css import order, allowed providers, and more).
A design system’s writable files follow this structure:
  • components/<Name>/index.tsx — component source (PascalCase folder, named exports only)
  • components/<Name>/<Name>.previews.tsx — preview definitions (required per component)
  • components/<Name>/Context.md — AI/usage documentation (required per component)
  • index.css — design system styles / Tailwind imports (editable, cannot be deleted)
  • tailwind.config.js — Tailwind configuration (editable, cannot be deleted)
  • rules/<slug>.md — design rules (rules/setup.md is the special “Setup” rule)
Shell / auto-generated files (root index.tsx, library.ts, registry.ts, etc.) are stripped automatically if sent.
get_design_system
Tool
Resolves a design system’s active artifact and lists its files. Always call this first — design systems are collaborative, so the active artifact ID can change between calls. Never reuse a cached artifactId.
read_design_system_files
Tool
Reads the contents of one or more files from a design system’s active artifact.
Call get_design_system first to discover available file names, and always read files before editing them so you preserve current content.
create_design_system
Tool
Creates a new, blank design system owned by you and returns its ID and editor URL. Seeds an empty initial version so you can immediately write files into it.
This creates a blank design system. Forking from an existing design system is not supported through the MCP. After creating, load the design_system_authoring_guide prompt and write files with write_design_system_files.
write_design_system_files
Tool
Creates or overwrites files in a design system. Incoming files are merged onto the existing artifact (existing files are preserved), then compiled and activated immediately.
This tool is permissive: it saves your files and returns validationErrors without blocking, so you can build incrementally. Fix all validation errors before calling publish_design_system, which is strict.
publish_design_system
Tool
Publishes the design system’s active artifact as a new immutable version.
This tool is strict: it refuses if the active artifact has validation errors. Run write_design_system_files and clear all validationErrors first. A breaking change (e.g. a removed component or prop) bumps the major version; otherwise the minor version is incremented.

Video Walkthrough

Getting existing code from your codebase into Magic Patterns: