stitch-native
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@stitch-native Convert screen.html into a SwiftUI view called MatchStatsView"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Quick start
uvx stitch-native swiftui screen.html > Screen.swiftRelated MCP server: Stitch MCP Server
Add to your agent
Client | Config |
Claude Code |
|
Claude Desktop / Cursor / VS Code | see JSON below |
{ "mcpServers": { "stitch-native": {
"command": "uvx",
"args": ["--from", "stitch-native", "stitch-native-mcp"] } } }Tools: stitch_to_native, stitch_to_swiftui, stitch_to_compose, stitch_to_html, extract_tokens, stitch_to_ir, init_config (source: html, path or url). Prompt: convert_screen. Resources: token-map and IR docs.
How it works
Stitch HTML + tailwind.config → DOM → IR (JSON: box / text / icon / image + styles) → emitterReads the Tailwind theme Stitch embeds (
colors,spacing,borderRadius,fontFamily,fontSize).Resolves each element's classes into a small layout IR (row / column / grid, padding, gap, radius, borders, text styles).
Emits SwiftUI, Compose or HTML. Colours that are not theme tokens are reported as off-token literals.
Usage
python3 stitch_native.py swiftui screen.html --name MatchStatsView > MatchStatsView.swift
python3 stitch_native.py compose screen.html --name MatchStatsScreen > MatchStatsScreen.kt
python3 stitch_native.py tokens screen.html > StitchTheme.swift
python3 stitch_native.py tokens-kotlin screen.html > StitchTheme.kt
python3 stitch_native.py html screen.html --name MatchStats > MatchStats.html
python3 stitch_native.py tokens-css screen.html > tokens.css
python3 stitch_native.py ir screen.html > screen.ir.json
# State mode: stateless screen + State struct/sample, keys, callbacks (no ViewModel)
python3 stitch_native.py swiftui fixtures/fornada-encomendas.html --name OrdersListView --mode state
python3 stitch_native.py compose fixtures/fornada-encomendas.html --name OrdersListScreen --mode state--mode state reads locale, timeZone, currency and key prefixes from stitch-native.json. Plug the screen into your own ViewModel/Coordinator: it only takes state and callbacks.
state.* config (all optional)
Key | What it does |
| Texts bound to |
| Field name for "Brand — Store" texts (default |
| Key prefix; source text or auto key → final L10n key; locale; rename a row struct or field ( |
| Semantic names. Key = source text, auto name ( |
| Sample value by final field name ( |
|
|
|
|
|
|
| Every case of the app's enum, in order. |
|
|
An existing enum must be a plain case enum (Hashable, no payloads). The Swift generated code uses Order.Status-style names verbatim, so the row struct must not be called Order (it is renamed automatically).
Targets
A project declares its ecosystem with targets in stitch-native.json: any of swiftui, compose, html. Without it (and without a targets argument) the tools emit swiftui + compose, as before. Unknown names are an error that lists the valid ones.
python3 stitch_native.py init screen.html --targets swiftui,html # writes only swiftui + html keys, stores targetsMCP
stitch_to_nativeandinit_configtake atargetsargument (it wins over the config).stitch_to_nativeemits only those targets and their theme files;init_configwrites only their keys (an iOS-only project gets noiconsComposeand nooutput.compose) and never deletes existing entries.Internally one registry (
TARGETSinstitch_native.py: emitter, theme function, fence language, owned config keys) drives the CLI, MCP andinit, so a new ecosystem is one registry entry plus its emitter.Config discovery (MCP): when no
config,maporconfig_pathis passed butpathis, the server reads the neareststitch-native.jsonnext to that file or in a parent directory (up to the filesystem root); otherwise it uses no config. The CLI keeps reading./stitch-native.json.
HTML target
html writes one self-contained page: a single <style> block (tokens as --color-*, --space-*, --font-* custom properties on :root, plus generated .s1, .s2… classes), semantic tags where the export has them (header, nav, main, section, h1…, ul, table…), and no Tailwind, no <script>, no external URLs. Fonts use the system stack (a token's own font name is tried first). Images keep their src; inline <svg> becomes an empty <span> with a TODO comment.
Material icons become
<span class="icon" data-icon="name">. Fill them withiconsHtml({"home": "⌂"}text or inline<svg>markup, used verbatim); unmapped names are listed (unmapped iconsHtmlininit,unmapped iconsin the report).Colours:
colorsHtml(token or#hex→ CSS value) wins;colorsentries are used only when they already look like a CSS value (#hex,var(...),rgb(...)…), so a Swift expression shared with the iOS target never lands in the CSS. Off-token literals are reported like for the other targets.Toasts and sheets are emitted
hidden; top and bottom bars areposition: sticky.Layout mode only:
--mode state/mode: "state"is an error forhtml;stitch_to_nativein state mode skips it with a warning.Examples:
examples/MatchStats.html,examples/OrdersList.html.
Map tokens to your design system
{ "colors": { "primary": "DS.Color.accent", "#12241c": "DS.Color.card" },
"fonts": { "headline-md": "DS.Font.title" } }python3 stitch_native.py init screen.html # writes stitch-native.json, lists unmapped tokens/icons
python3 stitch_native.py swiftui screen.html # auto-loads ./stitch-native.json (or --config path)stitch-native.json also takes targets, icons (Material → SF Symbol), iconsCompose
(Material → Icons.X.Y), iconsHtml, colorsHtml, preview.colorScheme and output folders. null entries fall back to the theme.
MCP server
stitch_native_mcp.py exposes the converter to any MCP client (stdio, no dependencies).
claude mcp add stitch-native -- python3 /path/to/stitch_native_mcp.pyTool | Does |
| Theme file for |
| Layout IR as JSON |
| SwiftUI view + off-token report |
| Compose composable + off-token report |
| Self-contained HTML page + off-token and unmapped-icon report (layout mode) |
| The configured targets (default swiftui + compose) in one call, with their theme files |
|
|
Each tool takes html (the export) or path; the code tools also take name and config (object) or config_path (else the nearest stitch-native.json next to path).
Pairs well with the official Stitch MCP: fetch the screen HTML there, convert here.
Example
fixtures/match-stats.html → examples/MatchStatsView.swift, examples/MatchStatsScreen.kt and examples/MatchStats.html.
Status
Prototype. Known gaps:
Output not yet compile-checked in CI.
SwiftUI drops the font weight when a family token and a
text-*size class share an element.Absolute positioning, animations and
hover:states are ignored.
Roadmap: visual_diff tool (render vs Stitch screenshot) and a Claude skill.
Releasing
Pushing a tag vX.Y.Z runs .github/workflows/publish.yml: tests, build, upload to PyPI (trusted publishing), then publish server.json to the MCP registry (GitHub OIDC). No secrets are stored. pyproject.toml, both versions in server.json and VERSION in stitch_native_mcp.py must agree (a unit test checks it); the tag must match too.
One-time manual step on pypi.org (Account → Publishing → "Add a new pending publisher"), before the first tag:
Field | Value |
PyPI project name |
|
Owner |
|
Repository name |
|
Workflow name |
|
Environment name |
|
Optionally create a GitHub environment named pypi (Settings → Environments) with required reviewers as a manual gate.
License
MIT
Available Tools
7 toolsextract_tokensB
Extract Stitch design tokens (colours, spacing) as a SwiftUI theme, a Compose theme or CSS custom properties (:root).
Inputs: url, html, path, platform.
init_configA
Build a stitch-native.json skeleton from the colours, fonts and icons a screen uses, merged over an existing config (existing entries win and are never deleted). Only the keys of the requested targets are written (iOS-only: no iconsCompose, no output.compose); an explicit targets is stored in the config. Returns the JSON and the unmapped entries to fill in.
Inputs: url, html, path, targets, +2 more.
stitch_to_composeB
Convert a Stitch screen to a Jetpack Compose (Material 3) composable. Reports off-token colours and warnings.
Inputs: url, html, mode, name, +3 more.
stitch_to_htmlB
Convert a Stitch screen to one self-contained HTML page (a single block with tokens as CSS custom properties, semantic tags, no script, no external URLs). Layout mode only. Material icons become filled from the config's iconsHtml; unmapped icons are listed.
Inputs: url, html, mode, name, +3 more.
stitch_to_irB
Parse a Stitch screen into the platform-neutral layout IR (JSON).
Inputs: url, html, path.
stitch_to_nativeB
Convert one Stitch screen to the project's targets in one call (swiftui, compose, html; default = the config's targets, else swiftui + compose), plus the theme file of each. In state mode html is skipped with a warning.
Inputs: url, html, mode, name, +4 more.
stitch_to_swiftuiB
Convert a Stitch screen to a SwiftUI view. Reports off-token colours and warnings.
Inputs: url, html, mode, name, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a distinct output artifact (IR, Compose, SwiftUI, HTML, theme tokens, config skeleton), but stitch_to_native explicitly aggregates the per-target converters, so an agent must decide between the batch tool and the individual ones. extract_tokens vs init_config both deal with colours/spacing and could be momentarily confused, though descriptions clarify (theme output vs config JSON).
Five tools follow a clean stitch_to_<target> pattern, with extract_tokens and init_config as verb_noun actions in the same snake_case style. The mix of a common prefix family and two standalone verbs is readable and predictable.
Seven tools is well-scoped for a screen-to-code converter: one per target, one aggregate, plus IR, tokens and config. No tool feels redundant enough to remove, and none of the workflow is missing a slot.
The surface covers the full pipeline: parse (IR), per-target conversion, tokens, batch native export, and config bootstrapping. Minor gaps remain — no config validation/inspection tool or way to list/map icons beyond init_config's output, and no additional targets (e.g. Flutter/XML) if those are in scope.
Maintenance
Related MCP Connectors
UI design from prompts, screenshots, and URLs for AI coding agents and theme tokens.
Deterministic Figma to Elementor, Gutenberg, Oxygen, Etch and HTML layouts for AI assistants.
Collaborative design board for AI agents: screens in HTML + Tailwind, edited live with your team.
Real HTML, styles, measurements and brand tokens from any live site, for coding agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn intelligent MCP server for Google Stitch that generates production-ready UI from text prompts, with auto-orchestration of design systems, WCAG accessibility, responsive breakpoints, and framework conversion (React, Vue, Svelte).1718 npm9MIT
- AlicenseAqualityDmaintenanceEnables AI coding assistants to generate, edit, and scaffold HTML UIs from natural language using Google Stitch API.9348 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA CLI and MCP server to preview, build, and integrate AI-generated UI designs from Google Stitch into your local development workflow and coding agents.7,376 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceBrings Google Stitch design tools into AI assistants, enabling browsing projects, viewing screen designs, extracting design tokens, and generating new screens via natural language.3MIT