# Stitch Documentation Source collection: https://stitch.withgoogle.com/docs Extracted: 2026-05-22T08:52:08.247Z This file contains Markdown converted from the accessible rendered documentation pages discovered at stitch.withgoogle.com/docs. Each page section includes its source URL. ## Pages - [Start with a prompt. Iterate into a design.](#start-with-a-prompt-iterate-into-a-design-) - https://stitch.withgoogle.com/docs/ - [Everything you need to know to design with Stitch](#everything-you-need-to-know-to-design-with-stitch) - https://stitch.withgoogle.com/docs/learn/overview/ - [Effective Prompting](#effective-prompting) - https://stitch.withgoogle.com/docs/learn/prompting/ - [Device Types](#device-types) - https://stitch.withgoogle.com/docs/learn/device-types/ - [Design Modes](#design-modes) - https://stitch.withgoogle.com/docs/learn/design-modes/ - [Using Variations](#using-variations) - https://stitch.withgoogle.com/docs/learn/variants/ - [Controls & Hotkeys](#controls-hotkeys) - https://stitch.withgoogle.com/docs/learn/controls/ - [Open Source Licenses](#open-source-licenses) - https://stitch.withgoogle.com/docs/learn/licenses/ - [Stitch via MCP](#stitch-via-mcp) - https://stitch.withgoogle.com/docs/mcp/setup/ - [Getting Started](#getting-started) - https://stitch.withgoogle.com/docs/mcp/guide/ - [Reference](#reference) - https://stitch.withgoogle.com/docs/mcp/reference/ - [Build your first design](#build-your-first-design) - https://stitch.withgoogle.com/docs/sdk/tutorial/ - [Use with AI SDK](#use-with-ai-sdk) - https://stitch.withgoogle.com/docs/sdk/ai-sdk/ - [Agent-driven workflows](#agent-driven-workflows) - https://stitch.withgoogle.com/docs/sdk/agent-workflows/ - [How to edit a screen](#how-to-edit-a-screen) - https://stitch.withgoogle.com/docs/sdk/edit-screen/ - [How to generate variants](#how-to-generate-variants) - https://stitch.withgoogle.com/docs/sdk/generate-variants/ - [How to download artifacts](#how-to-download-artifacts) - https://stitch.withgoogle.com/docs/sdk/download-artifacts/ - [How to extract themes](#how-to-extract-themes) - https://stitch.withgoogle.com/docs/sdk/extract-themes/ - [How to manage design systems](#how-to-manage-design-systems) - https://stitch.withgoogle.com/docs/sdk/design-systems/ - [How to upload files](#how-to-upload-files) - https://stitch.withgoogle.com/docs/sdk/upload-image/ - [Reference](#reference) - https://stitch.withgoogle.com/docs/sdk/reference/ - [Architecture](#architecture) - https://stitch.withgoogle.com/docs/sdk/architecture/ - [What is DESIGN.md?](#what-is-design-md-) - https://stitch.withgoogle.com/docs/design-md/overview/ - [Import from your codebase](#import-from-your-codebase) - https://stitch.withgoogle.com/docs/design-md/get-instructions/ - [The DESIGN.md specification](#the-design-md-specification) - https://stitch.withgoogle.com/docs/design-md/specification/ - [View, edit, and export](#view-edit-and-export) - https://stitch.withgoogle.com/docs/design-md/usage/ - [Validate with the CLI](#validate-with-the-cli) - https://stitch.withgoogle.com/docs/design-md/cli/ - [Linting rules](#linting-rules) - https://stitch.withgoogle.com/docs/design-md/linting-rules/ - [Get started with Agent Skills](#get-started-with-agent-skills) - https://stitch.withgoogle.com/docs/skills/get-started/ - [Code to Design roundtrip](#code-to-design-roundtrip) - https://stitch.withgoogle.com/docs/skills/roundtrip/ - [Build in a loop](#build-in-a-loop) - https://stitch.withgoogle.com/docs/skills/build-in-a-loop/ - [Generate walkthrough videos](#generate-walkthrough-videos) - https://stitch.withgoogle.com/docs/skills/walkthrough-videos/ - [Taste](#taste) - https://stitch.withgoogle.com/docs/skills/taste/ - [Skill reference](#skill-reference) - https://stitch.withgoogle.com/docs/skills/reference/ ## Start with a prompt. Iterate into a design. Source: https://stitch.withgoogle.com/docs/ Stitch transforms your ideas into designs through AI-powered iteration. Whether you’re building web apps, mobile experiences, or prototypes, start here. ### Try it yourself PROMPT IDEA A landing page for a running podcast named “The Pacing Project”. THEME Modern, edgy, high contrast. Use black and white with hard angles. CONTENT Hero section with “Stories and lessons about racing and proper pacing” and links to podcast platforms. ### What you’ll find here #### Learn Stitch Master effective prompting, design modes, device types, and iteration techniques. Everything you need to create with Stitch. Prompting Device Types Design Modes Controls #### MCP Integration Connect Stitch to AI agents via Model Context Protocol. Automate design workflows and integrate with your development pipeline. Setup Authentication API Reference ## Everything you need to know to design with Stitch Source: https://stitch.withgoogle.com/docs/learn/overview/ A subtly opinionated walkthrough Stitch Welcome to Stitch. Today you’re learning to start with design and lean into ideation. The key is not to overthink it. ### The key to better prompts and better designs Section titled “The key to better prompts and better designs” **Ideate.** The hardest part is getting past the blank page. The best way to create better designs is through iteration, not perfect initial prompts. Let’s follow a simple formula. ### Starting prompt examples Section titled “Starting prompt examples” A good recipe for an initial prompt follows this formula: PROMPT IDEA What it is. THEME The idea for the core theme. CONTENT The content. IMAGE Optional reference image. Your first prompt doesn’t need to be perfect. Describe the specific content you want on the page and the general vibe. Don’t worry about specific font selections or hex codes yet. Stitch will help you with this ideation process. We need to get past the blank prompt and into creativity. Here’s an example. PROMPT IDEA A landing page for a running podcast named “The Pacing Project”. THEME Modern, edgy, and high contrast. Use black and white with hard angles. CONTENT A hero section with the headline “Stories and lessons about racing and proper pacing” and links to podcast platforms. #### Selecting the device type Section titled “Selecting the device type” App or Web? Just pick one. Don’t worry too much about the device type at first. Take a quick gut check on which format you think is most suitable at first. Stitch has plenty of ways to convert one mode to another as you iterate. Now hit generate. ### Navigating and controlling the canvas Section titled “Navigating and controlling the canvas” Let’s get comfortable with the canvas. #### Hotkeys Section titled “Hotkeys” Think of your two main interactions with the canvas in two modes: Selection and Navigation. The `V` key toggles the `Select` tool, while the `H` key toggles the `Pan` tool for quick drag-based navigation. Because the canvas is vast, it can be easy to lose track of where you are. If that ever happens, hit `⌘←` / `Ctrl+←` to navigate to the nearest screen. You can cycle through screens using `⌘→` / `Ctrl+→` and `⌘←` / `Ctrl+←`. For a whole list of shortcuts hit `?` to see all the hotkeys available. ### Starting the ideation process Section titled “Starting the ideation process” The real ideation process begins once the design appears. Odds are you’ll find several aspects of the initial generation that you like and others you dislike. Stitch has tools to tweak the dislikes and lean further into what the generation got right. ### Make one major change at a time Section titled “Make one major change at a time” Pick one thing you want to change, just one. Select the Screen you want to change, click Edit, Add to Chat, and write a prompt. **Be specific about what to change and how to change it.** For example, if the pricing table needs to emphasize the best value tier: Target specific component Specific visual instruction UI/UX Keyword Update the pricing table to emphasize the middle card. Increase its container height and add a drop shadow. Reduce the scale of the sibling cards to create a clear visual hierarchy. You can keep this formula going: find one change, write a clear and targeted prompt using UI/UX keywords, and generate. #### Edit Theme Section titled “Edit Theme” If your change is within the core theme of the design, Stitch has a specific feature to work faster and target those specific changes. Select the Screen, click Generate and then Edit Theme. Here you can change core aspects of the theme such as the Light or Dark mode appearance, accent color, the corner radius of components, and font. #### Design to Prototype Section titled “Design to Prototype” Once you have your design in a more preferred state, let’s take it for a bit of a test drive. Click the screen, click Generate, and then Prototype. This creates a scrollable and interactive prototype that helps you get a feel for what the design is like in action. Here you can check interactive states that aren’t visible in a static design. Check out the hover styles for components like buttons, links, and cards. Write a message in a textbox and see if it’s too small or big for the typical amount of text expected. Think about how this prototype is going to be used in the wild. From there, continue to ideate based on these new interactive factors. #### Download code and images Section titled “Download code and images” When you’re ready to take your design and bring it to life, it’s time to download the code and images. Stitch creates designs for both image and HTML code outputs. Click a screen or drag and select all the screens you want to export. Click download. This will download a zip file to your device and from here you can integrate it into many different tools to make it real. #### HTML converts to many formats Section titled “HTML converts to many formats” It’s important to understand that the HTML code serves as a base for translation. LLMs excel at taking HTML combined with a reference image and converting it to other component formats such as React, Angular, and Vue, or non-web platforms such as Jetpack Compose, Flutter, and SwiftUI. To learn about generating specific component formats, check out the Build Strategies section. ### Keep ideating. Keep creating. Section titled “Keep ideating. Keep creating.” The key to better results is effective prompting and ideation. Keep ideating until you find the design that feels right. ## Effective Prompting Source: https://stitch.withgoogle.com/docs/learn/prompting/ Effective practices to iterate towards effective results Stitch This guide provides instructions for crafting effective prompts to design and refine your app with Stitch. ### Starting Your Project Section titled “Starting Your Project” Choose to start with a broad concept or specific details. For complex apps, start high-level and then drill down on details screen by screen. #### High-Level vs. Detailed Prompts Section titled “High-Level vs. Detailed Prompts” Start with a general idea. PROMPT HIGH-LEVEL An app for marathon runners. Describe core functionalities for a better starting point. PROMPT DETAILED An app for marathon runners to engage with a community, find partners, get training advice, and find races near them. #### Set the Vibe with Adjectives Section titled “Set the Vibe with Adjectives” Use adjectives to define the app’s feel (influences colors, fonts, imagery). PROMPT ADJECTIVES A vibrant and encouraging fitness tracking app. PROMPT ADJECTIVES A minimalist and focused app for meditation. ### Refining Your App by Iterating Screen by Screen Section titled “Refining Your App by Iterating Screen by Screen” #### Refine with Specific, Incremental Changes Section titled “Refine with Specific, Incremental Changes” Stitch performs best with clear, specific instructions. Focus on one screen/component and make one or two adjustments per prompt. - **Be Specific:** Tell Stitch _what_ to change and _how_. Target specific element Target specific screen Specific visual change Reference brand theme Change the primary call-to-action button on the login screen to be larger and use the brand’s primary blue color. - **Focus on Specific Screens/Features:** #### Describe Desired Imagery Section titled “Describe Desired Imagery” Guide the style or content of images. - **Specific Image Style:** “Music player page for ‘Suburban Legends.’ Album art is a macro, zoomed-in photo of ocean water. Page background/imagery should reflect this.” ### Controlling App Theme Section titled “Controlling App Theme” #### Colors Section titled “Colors” Request specific colors or describe a mood for the color palette. - **Specific Color Prompt:** `"Change primary color to forest green."` - **Mood-Based Color Prompt:** `"Update theme to a warm, inviting color palette."` #### Fonts & Borders Section titled “Fonts & Borders” Modify typography and element styling (buttons, containers). - **Font Style Prompt:** `"Use a playful sans-serif font."` OR `"Change headings to a serif font."` - **Border/Button Style Prompt:** `"Make all buttons have fully rounded corners."` OR `"Give input fields a 2px solid black border."` PROMPT COMBINED THEME Book discovery app: serif font for text, light green brand color for accents. ### How to Modify Images in Your Design Section titled “How to Modify Images in Your Design” #### Be Specific When Changing Images Section titled “Be Specific When Changing Images” Clearly identify the image to modify. Use descriptive terms from the app’s content. - **Targeting General Images:** `"Change background of [all] [product] images on [landing page] to light taupe."` - **Targeting a Specific Image:** Define location Describe content to target Instruction On ‘Team’ page, image of ‘Dr. Carter (Lead Dentist)’: update her lab coat to black. #### Coordinate Images with Theme Changes Section titled “Coordinate Images with Theme Changes” If updating theme colors, specify if images should also reflect these changes. - **Prompt:** `"Update theme to light orange. Ensure all images and illustrative icons match this new color scheme."` ### Changing the Language of Your App’s Text Section titled “Changing the Language of Your App’s Text” Use the following prompt: - **Prompt:** `"Switch all product copy and button text to Spanish."` ### Pro Tips for Stitch Section titled “Pro Tips for Stitch” - **Be Clear & Concise:** Avoid ambiguity. - **Iterate & Experiment:** Refine designs with further prompts. - **One Major Change at a Time:** Easier to see impact and adjust. - **Use UI/UX Keywords:** (e.g., “navigation bar,” “call-to-action button,” “card layout”). - **Reference Elements Specifically:** (e.g., “primary button on sign-up form,” “image in hero section”). - **Review & Refine:** If a change isn’t right, rephrase or be more targeted. ## Device Types Source: https://stitch.withgoogle.com/docs/learn/device-types/ How to choose your canvas and translate designs between App and Web. Stitch When you start a project, Stitch asks you to make a choice: **App** or **Web**. This isn’t just about screen size; it is about defining your **Primary Design Surface**. The device type dictates how Stitch interprets layout, navigation, and hierarchy. ### Layouts rely on context Section titled “Layouts rely on context” - **App Mode:** Optimizes for vertical scrolling, bottom-aligned navigation (thumb zones), and stacked content. - **Web Mode:** Optimizes for horizontal sprawl, top-aligned navigation, and multi-column grids. A sceen designed in **App Mode** will look like a large app when viewed on a desktop. Conversely, a **Web Mode** design squeezed onto phone screen often loses critical details and UI components expected on native mobile apps. ### Designing between modes Section titled “Designing between modes” The best way to move from one platform to another is not to resize, but to **translate**. Stitch If you have a mobile app design and want a web version, draft a prompt that describes what needs to change to optimize the design for that device type. First, use an existing design as a **Reference Image** for a new project or an update for a new screen. A new screen can be tricky in the way Stitch currently works but we’ll detail some ways to help smooth that over below. #### Phase 1: The App Design Section titled “Phase 1: The App Design” Let’s look at an example for this _Raffinato_ app. _Raffinato means refined in Italian._ This project started in **App Mode** because the mobile ordering flow was most important. PROMPT IDEA An ordering app for a local quality obsessed espresso focused coffee shop named Raffinato. THEME A light, high contrast theme with a modern and minimalistic feel. CONTENT Prefer a variable sized grid layout: 1 column on one row, followed by 2 columns on the next. Break up the grid into sections with labels categorizing the types of drinks in each section. Provide a mobile ordering layout for common espresso drinks with placeholder values for prices. Focus on the typographic balance for menu items placing the visual emphasis on the item name and less emphasis on details such as size in ounces, and price. NAVIGATION Provide navigation to easily switch screens between main grid, details, and the cart. This generates a tight, vertical interface perfect for a phone. #### Phase 2: Translating to Web Section titled “Phase 2: Translating to Web” To move to Web, either create a **New Project** set to **Web Mode** or provide an update prompt in the existing project, and use a screen’s downloaded image as a reference. Your goal now is to tell Stitch how to utilize the larger screen real estate. Focus on core UI/UX aspects that need to change, such as the **Navigation**, the **Hero Section**, and the **Grid Density**. Here is how the prompt handles the device type translation: PROMPT NAVIGATION Consolidate the bottom tab bar and top menu into a single, horizontal navigation bar at the top of the screen with links for Home, Menu, Rewards, and Account. HERO Transform ‘The Daily Focus’ card into a split-layout hero section. Place the Cortado text and button on the left, and expand the image to cover the right side. GRID LAYOUT Update the product lists from a 2-column mobile layout to a 4-column desktop grid. Maintain the light cream card background and minimalist vibe. By explicitly telling Stitch to move the navigation to the top and split the hero content, the prompt focuses on retaining the _feel_ of the brand and optimizing the design for the utility of the device type. ### Switching Device Types in the same project Section titled “Switching Device Types in the same project” When you create a Stitch project with a specific device type it will continue to generate screens of that device type’s size. You can give Stitch a prompt to convert to another device type within the same project, but it requires manual finessing. If you generate a Web prompt inside an App project, Stitch will generate the web content inside an app frame. 1. **Generate** the design. 2. Use **Preview > Device Type** to switch the view to the intended target (e.g., Desktop). 3. **Resize** the frame manually if elements feel cut off. #### Pro Tip: The Hidden Content Section titled “Pro Tip: The Hidden Content” When switching from App to Web within a project, try increasing the vertical height of the design frame significantly. Stitch often generates the “rest” of the website logic, but hides it because the original App frame was too short. Dragging the frame handle down can reveal the rest of your layout. ## Design Modes Source: https://stitch.withgoogle.com/docs/learn/design-modes/ Select the right engine for your creative workflow. Stitch Stitch isn’t just one AI model; it is a suite of design engines. In the generation settings, you will find the **Design Mode** selector. Think of these not just as different “versions,” but as different specialized tools. Some are built for speed, some for raw creativity, and others for deep logic and reasoning. ### Thinking with 3 Pro Section titled “Thinking with 3 Pro” **Best for:** Complex logic, deep reasoning, and your “Production” candidate. This is the heavy lifter. Powered by Gemini 3 Pro, this mode prioritizes **reasoning over speed**. It takes a little longer to generate because it is “thinking” through the implications of your prompt—how the navigation should flow, what the hierarchy implies, and how the colors interact. If you are building a complex dashboard or a nuance-heavy landing page, this is where you should be. The wait is worth the pixel-perfect logic it returns. ### Redesign (Nano Banana Pro) Section titled “Redesign (Nano Banana Pro)” **Best for:** Modernizing old apps, stylistic experiments, and “vibes” based workflows. The Redesign agent is your best friend when it comes to Vibe Design. It is incredible for taking a dated interface and applying a specific design aesthetic. #### The Style Word Bank Section titled “The Style Word Bank” The Redesign agent thrives on specific art-direction keywords. Instead of saying “make it look cool,” try combining terms from these categories to define a distinct visual language. **Layout & Structure** - **Bento Grid:** Modular, boxy, card-based layouts. Distinct compartments that organize content into a cohesive, grid-like hierarchy. - **Editorial:** High-fashion magazine feel. Large serif headings, generous whitespace, asymmetrical image placement. - **Swiss Style:** Objectively clear. Heavy reliance on grid systems, sans-serif typography (Helvetica-ish), and flush-left text. - **Split-Screen:** Distinct vertical division, often pairing a solid color block with full-bleed imagery. **Texture & Depth** - **Glassmorphism:** Translucency, background blur (backdrop-filter), and subtle white borders. “Frosted glass.” - **Claymorphism:** Soft, inflated 3D shapes with inner shadows. Friendly, approachable, and tactile. - **Skeuomorphic:** Realistic textures (leather, paper, metal) and controls that look like physical switches. - **Grainy/Noise:** Adding film grain or texture overlays to gradients to reduce the “digital” shine and add warmth. **Atmosphere & Era** - **Brutalist:** Raw, unpolished, default system fonts, high contrast, hard edges. “Ugly-cool.” - **Cyberpunk:** Dark mode, neon accents (cyan/magenta), glitch effects, tech-heavy interfaces. - **Y2K:** Late 90s/Early 2000s optimism. Chrome textures, bubble letters, bright blues and pinks, pill-shaped buttons. - **Retro-Futurism:** 80s Synthwave. Sunsets, wireframe grids, VHS aesthetics, glowing lines. **Color & Contrast** - **Duotone:** The entire UI is composed of two contrasting colors (and their shades). - **Monochromatic:** Using a single base hue (e.g., “Shades of Electric Blue”) for a cohesive, branded look. - **Pastel Goth:** Soft, milky pastel colors paired with stark black typography and borders. - **Dark Mode OLED:** True black backgrounds (#000000) rather than dark grey, optimized for high contrast and pop. PROMPT ACTION Redesign this dashboard. STYLE Use a modern Bento Grid layout. DETAILS Dark mode background. Use the Inter font for the headers. ### 2.5 Pro Section titled “2.5 Pro” **Best for:** High-fidelity HTML and A/B comparisons. Gemini 2.5 Pro produces exceptionally high-quality code and design fidelity. It is often useful to generate a prompt in **Thinking with 3 Pro** and then run the exact same prompt in **2.5 Pro** to see two different high-level interpretations of your idea. ### Fast Section titled “Fast” **Best for:** Rapid wireframing and Figma exports. The Rapid mode is optimized for compatibility if your primary goal is to export your initial sketches directly to **Figma** for manual refinement. ## Using Variations Source: https://stitch.withgoogle.com/docs/learn/variants/ Variations are one of the most powerful and fun to use features in Stitch. They allow you to generate multiple design options at once, breaking you out of a linear workflow and showing you possibilities you might not have imagined. You are really good at exploring multiple versions of a design and comparing them, so it seems a waste to only generate one option at a time! Currently, you can generate anywhere from one to five different options at a time. This feature is your sandbox for “What if?” moments. ### When to use variations Section titled “When to use variations” While the standard Chat is great for specific, granular updates (like changing a button color), Variations are best used for: - **Getting Unstuck:** If you don’t know what to change, but you know the current design isn’t working. - **Exploration:** When you want to see three different layout concepts for the same content. - **Pivoting:** When you want to change the entire vibe (e.g., from “Corporate Blue” to “Neon Cyberpunk”) in one go. ### Controlling the Creative Range Section titled “Controlling the Creative Range” Each time you generate variations, you specify the **Creative Range** to give Stitch. This tells the AI how far to stray from your current design: - **Refined (Low Range):** Keeps the structure intact but plays with fonts, subtle spacing, and colors. Use this for polish. - **Creative (High Range):** Absolute “let’s see what’s possible” freedom. This allows Stitch to completely restructure the layout, swap imagery, and overhaul the theme. ### Writing prompts for Variations Section titled “Writing prompts for Variations” Unlike the standard editing process where we recommend making “one major change at a time,” Variations are the place to make **big swings**. You can combine theme changes and layout changes into a single prompt because you are generating multiple options to choose from. Sets the vibe Specific color request Target specific screen Clear, specific instruction Update the app theme to a luxury aesthetic using a strict black and white palette. On the Episode List screen, change the layout to a minimalist grid. **Pro Tip:** Even when asking for broad changes, be specific about the _direction_. Instead of saying “Make it different,” say “Make it minimalist” or “Make it bold.” ### Iterating on a winner Section titled “Iterating on a winner” The power of variations doesn’t stop after the first click. Once Stitch presents you with five options, you might find that Option 3 has the perfect layout, but Option 5 has the better color scheme. 1. **Pick the best base:** Select the variation that is closest to your vision. 2. **Vary the variation:** You can run variations _on top_ of a variation. Select your winner, lower the **Creative Range** to “Refined,” and ask Stitch to bring in the color scheme you liked from the other option. ## Controls & Hotkeys Source: https://stitch.withgoogle.com/docs/learn/controls/ Master the canvas with keyboard shortcuts and powerful navigation tools. ### Controls & Hotkeys Section titled “Controls & Hotkeys” Stitch is designed for speed. The more comfortable you get with keyboard shortcuts and canvas tools, the faster you’ll move from concept to polished design. ### Quick Access to Shortcuts Section titled “Quick Access to Shortcuts” Press **?** at any time to bring up the complete list of keyboard shortcuts. This modal shows every available shortcut organized by category, with platform-specific modifiers displayed correctly (⌘ on Mac, Ctrl on Windows/Linux). **Pro Tip:** The shortcuts modal is your reference guide. If you forget a hotkey mid-workflow, tap **?** to quickly look it up without breaking your flow. ### Core Keyboard Shortcuts Section titled “Core Keyboard Shortcuts” These are the shortcuts you’ll use most often. They’re designed to keep your hands on the keyboard and your focus on the canvas. #### Edit Actions Section titled “Edit Actions” - **Undo**: `⌘Z` / `Ctrl+Z` - **Redo**: `⌘⇧Z` / `Ctrl+Shift+Z` - **Copy**: `⌘C` / `Ctrl+C` - **Paste**: `⌘V` / `Ctrl+V` - **Duplicate**: `⌘D` / `Ctrl+D` — Quickly clone selected screens - **Delete**: `Backspace` or `Delete` - **Select All**: `⌘A` / `Ctrl+A` #### Canvas Tools Section titled “Canvas Tools” These shortcuts let you switch between different canvas interaction modes: - **Select Tool**: `V` — The default tool for selecting and moving screens - **Pan Tool**: `H` — Drag to navigate around the canvas - **Zoom Tool (hold)**: `Z` — Click to zoom in, Alt+click to zoom out, or drag to zoom to a specific area #### View Controls Section titled “View Controls” - **Zoom In**: `+` or `=` or `⌘=` / `Ctrl+=` - **Zoom Out**: `-` or `⌘-` / `Ctrl+-` - **Fit to View**: `0` or `⌘1` / `Ctrl+1` — Zoom to fit all content #### Project Actions Section titled “Project Actions” - **Save**: `⌘S` / `Ctrl+S` - **Download Selected Screen(s)**: `⇧D` / `Shift+D` ### Command Palette (⌘K) Section titled “Command Palette (⌘K)” Press **⌘K** (Mac) or **Ctrl+K** (Windows/Linux) to open the Command Palette. This is your universal search for all available actions in Stitch. The Command Palette shows every command that’s currently available, filtered by context: - **Active commands** appear first based on your current selection - Type to filter the list instantly - Use arrow keys to navigate, Enter to execute - Commands show their keyboard shortcuts on the right **Why use the Command Palette?** - Discover features you might not know exist - Execute actions without reaching for the mouse - See what’s possible in your current context **Pro Tip:** If you know roughly what you want to do but can’t remember the exact menu location, **⌘K** is the fastest way to find it. Type a few letters and the command you need will surface. ### Navigating the Canvas Section titled “Navigating the Canvas” Stitch projects can grow large quickly, with dozens of screens spread across the canvas. These shortcuts help you move efficiently. #### Screen Navigation Section titled “Screen Navigation” - **Next Screen**: `⌘→` / `Ctrl+→` — Jump to the next screen in reading order - **Previous Screen**: `⌘←` / `Ctrl+←` — Jump to the previous screen When you navigate between screens using these shortcuts, Stitch automatically: 1. Selects the target screen 2. Zooms to fit that screen in view 3. Centers it for optimal visibility **Reading Order:** Screens are ordered left-to-right, top-to-bottom—the same way you’d read a page. This makes navigation predictable even in complex projects. #### Lost on the Canvas? Section titled “Lost on the Canvas?” If you ever lose your bearings, press `⌘←` / `Ctrl+←` to snap to the nearest screen. Press `0` or `⌘1` / `Ctrl+1` to zoom out and see your entire project. ### Bottom Toolbar: Select, Pan, Zoom Section titled “Bottom Toolbar: Select, Pan, Zoom” The bottom toolbar shows three canvas tools. Each tool changes how you interact with the canvas. #### Tool Modes Section titled “Tool Modes” **Select Mode (`V`)** - Click to select screens - Drag to move screens - Click and drag on empty canvas to create a selection rectangle - This is the default mode—you’ll spend most of your time here **Pan Mode (`H`)** - Click and drag anywhere to move around the canvas - Useful for navigating large projects - No risk of accidentally selecting or moving screens **Zoom Mode (`Z`)** - **Click** to zoom in (centered on click position) - **Alt+Click** to zoom out - **Click and drag** to draw a rectangle—Stitch zooms to fit that area exactly - Press **Escape** to cancel an in-progress zoom selection #### Quick Access: Hold to Activate Section titled “Quick Access: Hold to Activate” You don’t need to permanently switch tools for quick actions. Stitch supports **temporary mode switching** for faster workflows: **Hold Space for Quick Pan** - In any mode, hold **Space** to temporarily switch to pan - Drag to reposition the canvas - Release **Space** to return to your previous tool **Hold Z for Quick Zoom** - Hold **Z** to temporarily switch to zoom mode - Perform your zoom action (click, Alt+click, or drag) - Release **Z** to return to your previous tool **Tap vs Hold** - **Tap** a key (`V`, `H`, or `Z`) to switch to that tool permanently - **Hold** a key (`Space` or `Z`) to activate temporarily—release to go back **Why this matters:** You can stay in Select mode for your main workflow, hold Space to quickly reposition the canvas, then release to keep selecting and editing. No extra clicks, no mode confusion. #### Visual Feedback Section titled “Visual Feedback” The active tool is always highlighted in the bottom toolbar, even during temporary mode switches. Your cursor also changes to match the current mode: - **Arrow** for Select - **Hand** for Pan (open hand when idle, closed fist when dragging) - **Magnifying glass** for Zoom (+ for zoom in, - for zoom out with Alt held) ### Putting It All Together Section titled “Putting It All Together” Here’s a typical workflow that combines these controls: 1. Press **⌘K** to open the Command Palette and generate a new screen 2. Press **⌘→** to navigate to the new screen (auto-zoom and select) 3. Use **V** to enter Select mode and click the screen 4. Hold **Space** to pan and position the screen perfectly 5. Tap **Z** and drag a rectangle around a specific component to zoom in 6. Press **⌘D** to duplicate the screen 7. Press **?** if you forget any shortcut along the way The goal is to keep you moving fast, staying in flow, and getting to great designs faster. ### Advanced Tip: Combine Shortcuts Section titled “Advanced Tip: Combine Shortcuts” Many shortcuts work together: - Select multiple screens, then press **⇧D** to download them all at once - Hold **Space** while in Zoom mode to temporarily pan without switching tools - Use **⌘A** to select all screens, then **⌘D** to duplicate your entire project layout Speed comes from muscle memory. The more you use these shortcuts, the less you’ll think about them—and the more you’ll think about your design. ## Open Source Licenses Source: https://stitch.withgoogle.com/docs/learn/licenses/ Open source licenses attribution for Stitch. Stitch is built with open source software. You can view the full list of open source licenses here: View Full Open Source Licenses File ## Stitch via MCP Source: https://stitch.withgoogle.com/docs/mcp/setup/ Connect IDEs and CLIs to Stitch using the Model Context Protocol. The Stitch Model Context Protocol (MCP) server allows your favorite AI tools like Cursor, Antigravity, or the Gemini CLI to directly interact with your Stitch projects. ### Understanding Remote MCP Section titled “Understanding Remote MCP” Most MCP servers you use are **Local**. They read files on your hard drive or run scripts on your machine. Stitch is a **Remote** MCP server. It lives in the cloud. Because it is remote, it requires a secure “handshake” to ensure that the AI agent acting on your behalf actually has permission to modify your designs. ### API Keys vs OAuth Section titled “API Keys vs OAuth” The Stitch MCP server supports two authentication methods: 1. **API Keys:** Persistent keys generated in the [Stitch Settings page](https://app-companion-430619.appspot.com/settings). 2. **OAuth:** A browser-based authentication flow required by specific AI clients that do not support manual key entry, or for environments where storing persistent secrets on disk is restricted. #### When to use which Section titled “When to use which” In most cases, API Keys are the easiest approach. They are the fastest way to get your tool connected. However, OAuth is worth the extra minute of setup in specific situations. | Scenario | Use API Keys if… | Use OAuth if… | | --- | --- | --- | | Client Support | Your tool (e.g., Cursor, Antigravity, or the Gemini CLI) accepts an API key in a config file or environment variable. | Your tool (e.g., web-based tools) requires a “Sign In” flow and doesn’t provide a way to manually input a key. | | Storage Policy | You are on a private machine where saving a secret key in a local .json or .env file is standard practice. | You are in a “Zero-Trust” or ephemeral environment where saving persistent secrets to the hard drive is blocked or risky. | | Revocation | You are comfortable manually deleting a key from the Stitch Settings page and then finding/removing it from your local files. | You want the ability to “Log Out” and instantly invalidate the tool’s access via the Stitch Settings page without hunting for local files. | | Session Logic | You want a connection that stays active indefinitely until you manually change it. | You prefer a session-based connection that can be set to expire or require a re-approval after a period of inactivity. | ### API Key Setup Section titled “API Key Setup” 1. Go to your [Stitch Settings page](https://app-companion-430619.appspot.com/settings). 2. Scroll to the API Keys section 3. Click on “Create API Key” to generate a new API key. 4. Copy the API key and save it in a secure location. [Stitch](https://app-companion-430619.appspot.com/settings) ### Storing API Keys Section titled “Storing API Keys” Never store your API key in a place where it can be exposed to the public. Never commit your API key to a public repository. Don’t include your API key in client-side code that can be viewed by others. ### MCP Client Setup Section titled “MCP Client Setup” #### Gemini CLI Section titled “Gemini CLI” Install the [Stitch extension](https://github.com/gemini-cli-extensions/stitch) for the Gemini CLI. ``` gemini extensions install https://github.com/gemini-cli-extensions/stitch ``` #### Cursor Section titled “Cursor” Create a `.cursor/mcp.json` file with the following entry: ``` { "mcpServers": { "stitch": { "url": "https://stitch.googleapis.com/mcp", "headers": { "X-Goog-Api-Key": "YOUR-API-KEY" } } } } ``` #### Antigravity Section titled “Antigravity” In the Agent Panel, click the three dots in the top right and select **MCP Servers**. Click, **Manage MCP Servers**. Select “View raw config” and add the following entry: ``` { "mcpServers": { "stitch": { "serverUrl": "https://stitch.googleapis.com/mcp", "headers": { "X-Goog-Api-Key": "YOUR-API-KEY" } } } } ``` #### VSCode Section titled “VSCode” Open the Command Palette (Cmd+Shift+P) and type “MCP: Add Server”. Select “Add MCP Server”. Select **HTTP** to add a remote MCP server. Enter the Stitch MCP URL, `https://stitch.googleapis.com/mcp`. Set the name to “stitch” and confirm. Then modify the `mcp.json` file to add the API key: ``` { "servers": { "stitch": { "url": "https://stitch.googleapis.com/mcp", "type": "http", "headers": { "Accept": "application/json", "X-Goog-Api-Key": "YOUR-API-KEY" } } } } ``` #### Claude Code Section titled “Claude Code” Use the `claude mcp` command to authenticate and add the following entry: ``` claude mcp add stitch --transport http https://stitch.googleapis.com/mcp --header "X-Goog-Api-Key: api-key" -s user ``` ### OAuth Setup Section titled “OAuth Setup” We need to generate two secrets to allow your MCP Client to talk to Stitch: 1. **Project ID:** The container for your work. 2. **Access Token:** The short lived key for to verify authentication for the project. #### 1. Install the Google Cloud SDK Section titled “1. Install the Google Cloud SDK” Stitch relies on the `gcloud` CLI for secure authentication. If you don’t have it, you can install it globally through this quickstart, or you can install it as a standalone like the instructions below. ##### Standalone Section titled “Standalone” ``` # Download and install (simplified for standard environments) curl https://sdk.cloud.google.com | bash exec -l $SHELL # Set local configuration to avoid prompts export CLOUDSDK_CORE_DISABLE_PROMPTS=1 ``` ##### Homebrew Section titled “Homebrew” ``` brew install --cask google-cloud-sdk ``` #### 2. Double-Layer Authentication Section titled “2. Double-Layer Authentication” You need to log in twice. Once as **You** (the user), and once as the **Application** (your local code/MCP client). ``` # 1. User Login (Opens Browser) gcloud auth login # 2. Application Default Credentials (ADC) Login # This allows the MCP server to "impersonate" you securely. gcloud auth application-default login ``` #### 3. Configure the Project & Permissions Section titled “3. Configure the Project & Permissions” Select your working project and enable the Stitch API. You must also grant your user permission to consume services. ``` # Replace [YOUR_PROJECT_ID] with your actual Google Cloud Project ID PROJECT_ID="[YOUR_PROJECT_ID]" gcloud config set project "$PROJECT_ID" # Enable the Stitch API gcloud beta services mcp enable stitch.googleapis.com --project="$PROJECT_ID" # Grant Service Usage Consumer role USER_EMAIL=$(gcloud config get-value account) gcloud projects add-iam-policy-binding "$PROJECT_ID" \ --member="user:$USER_EMAIL" \ --role="roles/serviceusage.serviceUsageConsumer" \ --condition=None ``` #### 4. Generate the Secrets (.env) Section titled “4. Generate the Secrets (.env)” Finally, we generate the Access Token and save it to a `.env` file. > This overwrites any existing `.env` file ``` # Print the token TOKEN=$(gcloud auth application-default print-access-token) # Note: This overwrites any existing .env file echo "GOOGLE_CLOUD_PROJECT=$PROJECT_ID" > .env echo "STITCH_ACCESS_TOKEN=$TOKEN" >> .env echo "Secrets generated in .env" ``` #### 5. Keeping it Fresh Section titled “5. Keeping it Fresh” **Note:** Access Tokens are temporary (usually lasting 1 hour). When your MCP client stops responding or says “Unauthenticated,” you need to: 1. Re-run the commands in **Step 4** to update your `.env` file 2. Copy the new `STITCH_ACCESS_TOKEN` value from `.env` into your MCP client config file Most MCP clients don’t automatically read from `.env` files, so you’ll need to manually update the token in your config file each time it expires. ### Setting up your MCP Client Section titled “Setting up your MCP Client” Copy the values from your `.env` file into your MCP client configuration. Replace the placeholders below with the actual values from your `.env` file: - `` → Value of `GOOGLE_CLOUD_PROJECT` from `.env` - `` → Value of `STITCH_ACCESS_TOKEN` from `.env` > [!IMPORTANT] You will need to manually update the `Authorization` header in your config file every hour when the access token expires. See **Step 5** above for the refresh workflow. #### Cursor Section titled “Cursor” Create a `.cursor/mcp.json` file with the following entry: ``` { "mcpServers": { "stitch": { "url": "https://stitch.googleapis.com/mcp", "headers": { "Authorization": "Bearer ", "X-Goog-User-Project": "" } } } } ``` #### Antigravity Section titled “Antigravity” In the Agent Panel, click the three dots in the top right and select **MCP Servers**. Click **Manage MCP Servers**. Select “View raw config” and add the following entry: ``` { "mcpServers": { "stitch": { "serverUrl": "https://stitch.googleapis.com/mcp", "headers": { "Authorization": "Bearer ", "X-Goog-User-Project": "" } } } } ``` #### VSCode Section titled “VSCode” Open the Command Palette (Cmd+Shift+P) and type “MCP: Add Server”. Select “Add MCP Server”. Select **HTTP** to add a remote MCP server. Enter the Stitch MCP URL, `https://stitch.googleapis.com/mcp`. Set the name to “stitch” and confirm. Then modify the `mcp.json` file to add the headers: ``` { "servers": { "stitch": { "url": "https://stitch.googleapis.com/mcp", "type": "http", "headers": { "Accept": "application/json", "Authorization": "Bearer ", "X-Goog-User-Project": "" } } } } ``` #### Claude Code Section titled “Claude Code” Use the `claude mcp` command to add the server: ``` claude mcp add stitch \ --transport http https://stitch.googleapis.com/mcp \ --header "Authorization: Bearer " \ --header "X-Goog-User-Project: " \ -s user # -s user: saves to $HOME/.claude.json # -s project: saves to ./.mcp.json ``` #### Gemini CLI Section titled “Gemini CLI” Install the [Stitch extension](https://github.com/gemini-cli-extensions/stitch) for the Gemini CLI: ``` gemini extensions install https://github.com/gemini-cli-extensions/stitch ``` ### Available Tools Section titled “Available Tools” Once authenticated, your AI assistant will have access to the following tools to manage your Stitch workflow. See the [Reference](https://stitch.withgoogle.com/docs/mcp/reference) for full schemas and details. #### Project Management Section titled “Project Management” - `create_project`: Creates a new container for your UI work. - `get_project`: Retrieves specific details for a single project. - `list_projects`: Retrieves a list of all your active designs. #### Screen Management Section titled “Screen Management” - `list_screens`: Fetches all screens within a specific project. - `get_screen`: Retrieves specific details for a single screen. #### AI Generation Section titled “AI Generation” - `generate_screen_from_text`: Creates a new design from a text prompt. - `edit_screens`: Edits existing screens using a text prompt. - `generate_variants`: Generates design variants of existing screens. #### Design Systems Section titled “Design Systems” - `create_design_system`: Creates a new design system with foundational design tokens. - `update_design_system`: Updates an existing design system. - `list_design_systems`: Lists all design systems for a project. - `apply_design_system`: Applies a design system to one or more screens. ### Terms of Service Section titled “Terms of Service” By using this product you agree to the terms and conditions of the following license: [Google APIs Terms of Service](https://console.cloud.google.com/tos?id=universal). ## Getting Started Source: https://stitch.withgoogle.com/docs/mcp/guide/ Get up and running and learn a few tips and tricks along the way. The Stitch MCP takes the power of generating designs from within the Stitch editor and right into your IDE, CLI, or whatever AI tool of choice. You can convert your designs right into your codebase and generate new screens. This gives you programmable and automatable control with Stitch. ### Before we begin Section titled “Before we begin” #### Authentication Section titled “Authentication” Before anything else, you’ll need to authenticate with the Stitch MCP. This guide assumes you’ve already authenticated with the Stitch MCP. Check out our [Setup and Authentication Guide](https://stitch.withgoogle.com/docs/mcp/setup) to get started. #### What coding agent to use? Section titled “What coding agent to use?” You can use any coding agent of your choice. The Stitch MCP server integrates into coding agents with support for remote HTTP MCP servers. #### What we’re building Section titled “What we’re building” A Stitch to [React](http://react.dev/) component system. Write a prompt and get a well structured set of React components from your Stitch design. ### Prompting Stitch Section titled “Prompting Stitch” Write a prompt asking to see your Stitch Projects and each screen within that project. PROMPT ACTION Show me my Stitch projects. FORMAT List out each screen under each project and its screen id. You’ll see a response that looks something like below, although it will vary across tools and model choice. ``` 1. Raffinato Coffee Store App Created: Jan 14, 2026 • Desktop • Light Mode • Private Screens (3): - Home Menu - Full Menu - Checkout ``` Each Stitch Project can contain a series of screens. These screens are what contain the code and the images of your design. #### Prompting for fun Section titled “Prompting for fun” The magic of MCP tools is the integration of contextual data retrieval with AI model intelligence. You can ask for understanding of your Stitch projects or instruct the agent to generate new designs and code based upon context on your local machine. Or, you can just ask it a fun question. PROMPT FOR FUN Tell me what my Stitch Projects say about me as a developer. This one is a lot of fun. If you run it and want to share, give us a shout on [Twitter / X](https://x.com/stitchbygoogle). Alright, back to real work. #### Prompting for code Section titled “Prompting for code” Once the agent knows what project or screen you want to work with, you can access the code or the generated image. PROMPT PROJECT + SCREEN Download the HTML code for the Full Menu screen in the Raffinato project. TOOL GUIDANCE Use a utility such as curl -L ACTION Create a file named ./tmp/${screen-name}.html with the HTML code. The HTML file is a complete `` document with a Tailwind CSS configuration specific to that design. #### HTML to other UI frameworks Section titled “HTML to other UI frameworks” LLMs excel at converting HTML to many different UI systems. This HTML file serves as a foundation. By prompting an agent not only can you convert HTML to React, Vue, or Handlebars but even UI frameworks outside of the web platform, such as Flutter and Jetpack Compose. #### Prompting for images Section titled “Prompting for images” Just like above, you can ask an agent for the image of your Stitch screen. PROMPT PROJECT + SCREEN Download the image for the Full Menu screen in the Raffinato project. TOOL GUIDANCE Use a utility such as curl -L ACTION Create a file named ./tmp/${screen-name}.png containing the image. Now you’ll have a local copy of your image. However, not much has happened yet. So let’s move this quickly along and convert an entire screen to React components. ### Using Agent Skills with Stitch MCP Section titled “Using Agent Skills with Stitch MCP” Many coding agents support the [Agent Skill Open Standard](https://agentskills.io/home). A skill encapsulates an instruction based prompt with a set of resources such as specific tool calls from a MCP server. This skill paradigm is a great fit for generating a React component system from the Stitch MCP. #### Creating the React component system Section titled “Creating the React component system” The `add-skill` library lets you install agent skills to the most commonly used coding agents right from a GitHub URL. ``` npx add-skill google-labs-code/stitch-skills --skill react:components --global ``` This skill provides the details to an agent to understand what Stitch tools to use, steps to run, and best practices for separating React components. If you want to check out exactly what it does, see our [Stitch Agent Skills GitHub repo](https://github.com/google-labs-code/stitch-skills). After it’s installed, you can write a prompt to trigger this skill and let it do the work. PROMPT SKILL TRIGGER Convert the Landing Page screen in the Podcast Project. The agent will get to work and leave you with a React app running on a [Vite](https://vite.dev/) local server. ## Reference Source: https://stitch.withgoogle.com/docs/mcp/reference/ | # | Tool | Category | Read-Only | | --- | --- | --- | --- | | 1 | create_project | Project Management | false | | 2 | get_project | Project Management | true | | 3 | list_projects | Project Management | true | | 4 | list_screens | Screen Management | true | | 5 | get_screen | Screen Management | true | | 6 | generate_screen_from_text | AI Generation | false | | 7 | edit_screens | AI Generation | false | | 8 | generate_variants | AI Generation | false | | 9 | create_design_system | Design Systems | false | | 10 | update_design_system | Design Systems | false | | 11 | list_design_systems | Design Systems | true | | 12 | apply_design_system | Design Systems | false | ### Tools Section titled “Tools” #### create_project Section titled “create_project” Creates a new Stitch project. A project is a container for UI designs and frontend code. ANNOTATIONS destructive ##### Input Section titled “Input” ``` { "type": "object", "properties": { "title": { "type": "string", "description": "Optional. The title of the project." } }, "required": [] } ``` ##### Output Section titled “Output” Returns the created `Project` resource with generated `name`, `title`, and metadata. ##### Example Prompts Section titled “Example Prompts” PROMPT Create a new Stitch project called ‘Marketing Site’ Start a new design project Set up a new project for my app #### get_project Section titled “get_project” Retrieves the details of a specific Stitch project using its project name. ANNOTATIONS readOnly ##### Input Section titled “Input” ``` { "type": "object", "properties": { "name": { "type": "string", "description": "Required. Resource name. Format: `projects/{project}`. Example: `projects/4044680601076201931`" } }, "required": ["name"] } ``` ##### Output Section titled “Output” Returns a `Project` resource object. ##### Example Prompts Section titled “Example Prompts” PROMPT Get the details of project 4044680601076201931 Show me the project info What’s in my project? #### list_projects Section titled “list_projects” Lists all Stitch projects accessible to the user. By default, it lists projects owned by the user. ANNOTATIONS readOnly ##### Input Section titled “Input” ``` { "type": "object", "properties": { "filter": { "type": "string", "description": "Optional. AIP-160 filter on `view` field. Supported: `view=owned` (default), `view=shared`." } }, "required": [] } ``` ##### Output Section titled “Output” Array of `Project` resource objects. ##### Example Prompts Section titled “Example Prompts” PROMPT List all my Stitch projects Show me my projects List shared projects #### list_screens Section titled “list_screens” Lists all screens within a given Stitch project. ANNOTATIONS readOnly ##### Input Section titled “Input” ``` { "type": "object", "properties": { "projectId": { "type": "string", "description": "Required. Project ID (e.g., '4044680601076201931'), without `projects/` prefix." } }, "required": ["projectId"] } ``` ##### Output Section titled “Output” Array of [`Screen`](https://stitch.withgoogle.com/docs/mcp/reference/index.html#screen) objects. ##### Example Prompts Section titled “Example Prompts” PROMPT List all screens in project 12345 Show me the designs in this project What screens are in my project? #### get_screen Section titled “get_screen” Retrieves the details of a specific screen within a project. ANNOTATIONS readOnly ##### Input Section titled “Input” ``` { "type": "object", "properties": { "name": { "type": "string", "description": "Required. Resource name. Format: `projects/{project}/screens/{screen}`" }, "projectId": { "type": "string", "description": "Required (deprecated). Project ID without prefix." }, "screenId": { "type": "string", "description": "Required (deprecated). Screen ID without prefix." } }, "required": ["name", "projectId", "screenId"] } ``` > `projectId` and `screenId` are deprecated in favor of `name` (resource name format), but all three are currently required. ##### Output Section titled “Output” Returns a [`Screen`](https://stitch.withgoogle.com/docs/mcp/reference/index.html#screen) object with `htmlCode`, `screenshot`, `figmaExport` file references and download URLs. ##### Example Prompts Section titled “Example Prompts” PROMPT Get the details of screen abc123 in project 12345 Show me the screen info Check the status of this screen #### generate_screen_from_text Section titled “generate_screen_from_text” Generates a new screen from a text prompt. This process normally takes **a few minutes**. Avoid retrying even when you encounter connection errors. Connection errors don’t necessarily mean failure, try using `get_screen` after a few minutes. If `output_components` contains suggestions, present them to the user. If accepted, call again with the suggestion as the new `prompt`. ANNOTATIONS destructive ##### Input Section titled “Input” ``` { "type": "object", "properties": { "projectId": { "type": "string", "description": "Required. Project ID without prefix." }, "prompt": { "type": "string", "description": "Required. Text prompt describing the screen to generate." }, "deviceType": { "type": "string", "enum": ["DEVICE_TYPE_UNSPECIFIED", "MOBILE", "DESKTOP", "TABLET", "AGNOSTIC"] }, "modelId": { "type": "string", "enum": ["MODEL_ID_UNSPECIFIED", "GEMINI_3_PRO", "GEMINI_3_FLASH", "GEMINI_3_1_PRO"] } }, "required": ["projectId", "prompt"] } ``` > `GEMINI_3_PRO` is deprecated. Use `GEMINI_3_1_PRO` or `GEMINI_3_FLASH` instead. ##### Output Section titled “Output” Returns generated [`Screen`](https://stitch.withgoogle.com/docs/mcp/reference/index.html#screen) objects and [`SessionOutputComponent`](https://stitch.withgoogle.com/docs/mcp/reference/index.html#sessionoutputcomponent) entries (text, suggestions, or design references). ##### Example Prompts Section titled “Example Prompts” PROMPT Generate a mobile login screen for project 12345 Design a dashboard page with charts and statistics Create a landing page with a hero section, features grid, and footer Build a settings page for a dark-themed app #### edit_screens Section titled “edit_screens” Edits existing screens using a text prompt. Similar to `generate_screen_from_text`, this process normally takes **a few minutes**. Avoid retrying even when you encounter connection errors. Connection errors don’t necessarily mean failure, try using `get_screen` after a few minutes. ANNOTATIONS destructive ##### Input Section titled “Input” ``` { "type": "object", "properties": { "projectId": { "type": "string", "description": "Required. Project ID without prefix." }, "selectedScreenIds": { "type": "array", "items": { "type": "string" }, "description": "Required. Screen IDs to edit, without `screens/` prefix." }, "prompt": { "type": "string", "description": "Required. Edit instruction." }, "deviceType": { "type": "string", "enum": ["DEVICE_TYPE_UNSPECIFIED", "MOBILE", "DESKTOP", "TABLET", "AGNOSTIC"] }, "modelId": { "type": "string", "enum": ["MODEL_ID_UNSPECIFIED", "GEMINI_3_PRO", "GEMINI_3_FLASH", "GEMINI_3_1_PRO"] } }, "required": ["projectId", "selectedScreenIds", "prompt"] } ``` > `GEMINI_3_PRO` is deprecated. Use `GEMINI_3_1_PRO` or `GEMINI_3_FLASH` instead. ##### Output Section titled “Output” Returns the updated [`Screen`](https://stitch.withgoogle.com/docs/mcp/reference/index.html#screen) objects. ##### Example Prompts Section titled “Example Prompts” PROMPT Change the button color to blue on screen abc123 Make the hero text larger and add a subtitle Add a navigation bar to these screens Switch the layout to a two-column grid #### generate_variants Section titled “generate_variants” Generates design variants of existing screens. ANNOTATIONS destructive ##### Input Section titled “Input” ``` { "type": "object", "properties": { "projectId": { "type": "string", "description": "Required. Project ID without prefix." }, "selectedScreenIds": { "type": "array", "items": { "type": "string" }, "description": "Required. Screen IDs to generate variants for." }, "prompt": { "type": "string", "description": "Required. Text guiding variant generation." }, "variantOptions": { "$ref": "#/$defs/VariantOptions", "description": "Required. Variant configuration." }, "deviceType": { "type": "string", "enum": ["DEVICE_TYPE_UNSPECIFIED", "MOBILE", "DESKTOP", "TABLET", "AGNOSTIC"] }, "modelId": { "type": "string", "enum": ["MODEL_ID_UNSPECIFIED", "GEMINI_3_PRO", "GEMINI_3_FLASH", "GEMINI_3_1_PRO"] } }, "required": ["projectId", "selectedScreenIds", "prompt", "variantOptions"] } ``` > `GEMINI_3_PRO` is deprecated. Use `GEMINI_3_1_PRO` or `GEMINI_3_FLASH` instead. ###### VariantOptions Section titled “VariantOptions” ``` { "type": "object", "properties": { "variantCount": { "type": "integer", "description": "Number of variants (1–5). Default: 3." }, "creativeRange": { "type": "string", "enum": ["CREATIVE_RANGE_UNSPECIFIED", "REFINE", "EXPLORE", "REIMAGINE"] }, "aspects": { "type": "array", "items": { "type": "string", "enum": ["VARIANT_ASPECT_UNSPECIFIED", "LAYOUT", "COLOR_SCHEME", "IMAGES", "TEXT_FONT", "TEXT_CONTENT"] } } } } ``` ##### Output Section titled “Output” Returns generated variant [`Screen`](https://stitch.withgoogle.com/docs/mcp/reference/index.html#screen) objects. ##### Example Prompts Section titled “Example Prompts” PROMPT Generate 3 variants of screen abc123 focusing on layout and color Reimagine my landing page with radical variations Create subtle refinements of these screens Show me 5 different color schemes for this design #### create_design_system Section titled “create_design_system” Creates a new design system for a project. Establishes foundational design tokens (colors, typography, shapes, appearance) that apply across all screens. ANNOTATIONS destructive ##### Input Section titled “Input” ``` { "type": "object", "properties": { "designSystem": { "$ref": "#/$defs/DesignSystem", "description": "Required. The design system to create." }, "projectId": { "type": "string", "description": "Optional. Project ID. If empty, creates a global (unassociated) asset." } }, "required": ["designSystem"] } ``` ###### DesignSystem Section titled “DesignSystem” ``` { "type": "object", "properties": { "displayName": { "type": "string", "description": "Required. Display name." }, "theme": { "$ref": "#/$defs/DesignTheme", "description": "Required. Theme configuration." } }, "required": ["displayName", "theme"] } ``` ###### DesignTheme Section titled “DesignTheme” ``` { "type": "object", "properties": { "colorMode": { "type": "string", "enum": ["COLOR_MODE_UNSPECIFIED", "LIGHT", "DARK"] }, "headlineFont": { "type": "string", "enum": ["FONT_UNSPECIFIED", "INTER", "DM_SANS", "GEIST", "..."] }, "bodyFont": { "type": "string", "enum": ["FONT_UNSPECIFIED", "INTER", "DM_SANS", "GEIST", "..."] }, "labelFont": { "type": "string", "enum": ["FONT_UNSPECIFIED", "INTER", "DM_SANS", "GEIST", "..."] }, "roundness": { "type": "string", "enum": ["ROUNDNESS_UNSPECIFIED", "ROUND_FOUR", "ROUND_EIGHT", "ROUND_TWELVE", "ROUND_FULL"] }, "customColor": { "type": "string", "description": "Required. Hex color seed for the dynamic color system." }, "colorVariant": { "type": "string", "enum": ["COLOR_VARIANT_UNSPECIFIED", "MONOCHROME", "NEUTRAL", "TONAL_SPOT", "VIBRANT", "EXPRESSIVE", "FIDELITY", "CONTENT", "RAINBOW", "FRUIT_SALAD"] }, "overridePrimaryColor": { "type": "string", "description": "Optional. Override primary color (hex)." }, "overrideSecondaryColor": { "type": "string", "description": "Optional. Override secondary color (hex)." }, "overrideTertiaryColor": { "type": "string", "description": "Optional. Override tertiary color (hex)." }, "overrideNeutralColor": { "type": "string", "description": "Optional. Override neutral color (hex)." }, "designMd": { "type": "string", "description": "Optional. Markdown design instructions." } }, "required": ["colorMode", "headlineFont", "bodyFont", "roundness", "customColor"] } ``` ##### Output Section titled “Output” Returns the created design system `Asset`. ##### Example Prompts Section titled “Example Prompts” PROMPT Create a dark mode design system with Inter font and round corners Set up a design system with blue as the primary color Create a brand identity with Geist font and minimal roundness #### update_design_system Section titled “update_design_system” Updates an existing design system. Identifies the asset by its `name` field. ANNOTATIONS destructive ##### Input Section titled “Input” ``` { "type": "object", "properties": { "name": { "type": "string", "description": "Required. Resource name. Format: `assets/{asset}`. Example: `assets/15996705518239280238`" }, "projectId": { "type": "string", "description": "Required. Project ID without prefix." }, "designSystem": { "$ref": "#/$defs/DesignSystem", "description": "Required. The updated design system content." } }, "required": ["name", "projectId", "designSystem"] } ``` > Uses the same [`DesignSystem`](https://stitch.withgoogle.com/docs/mcp/reference/index.html#designsystem) and [`DesignTheme`](https://stitch.withgoogle.com/docs/mcp/reference/index.html#designtheme) schemas as `create_design_system`. ##### Output Section titled “Output” Returns the updated design system `Asset`. ##### Example Prompts Section titled “Example Prompts” PROMPT Update the design system to use dark mode Change the font to Geist in our design system Update the roundness to fully rounded #### list_design_systems Section titled “list_design_systems” Lists all design systems for a project (or global design systems if no `projectId`). ANNOTATIONS readOnly ##### Input Section titled “Input” ``` { "type": "object", "properties": { "projectId": { "type": "string", "description": "Optional. Project ID. If empty, lists global design systems." } }, "required": [] } ``` ##### Output Section titled “Output” Array of `Asset` objects containing design systems. ##### Example Prompts Section titled “Example Prompts” PROMPT List all design systems in project 12345 Show me the available design systems What design systems do I have? #### apply_design_system Section titled “apply_design_system” Applies a design system to one or more screens, modifying their appearance to match the system’s tokens (colors, fonts, shapes). ANNOTATIONS destructive ##### Input Section titled “Input” ``` { "type": "object", "properties": { "projectId": { "type": "string", "description": "Required. Project ID without prefix." }, "selectedScreenInstances": { "type": "array", "items": { "$ref": "#/$defs/SelectedScreenInstance" }, "description": "Required. Screen instances to update (from `get_project`)." }, "assetId": { "type": "string", "description": "Required. Design system asset ID (from `list_design_systems`), without `assets/` prefix." } }, "required": ["projectId", "selectedScreenInstances", "assetId"] } ``` ###### SelectedScreenInstance Section titled “SelectedScreenInstance” ``` { "type": "object", "properties": { "id": { "type": "string", "description": "Required. The screen instance ID (NOT the source screen ID). Available from `get_project`." }, "sourceScreen": { "type": "string", "description": "Required. Resource name. Format: `projects/{project}/screens/{screen}`" } }, "required": ["id", "sourceScreen"] } ``` ##### Output Section titled “Output” Returns the updated [`Screen`](https://stitch.withgoogle.com/docs/mcp/reference/index.html#screen) objects. ##### Example Prompts Section titled “Example Prompts” PROMPT Apply the blue design system to all screens in project 12345 Restyle these screens with the brand identity Use design system abc to update my screens ### Shared Types Section titled “Shared Types” #### Screen Section titled “Screen” A generated screen design within a Stitch project. | Field | Type | Description | | --- | --- | --- | | name | string | Resource name. Format: projects/{project}/screens/{screen} | | id | string | (Deprecated) The screen id. | | title | string | Title of the screen. | | prompt | string | Prompt used to generate the screen. | | screenshot | File | Screenshot image of the screen. | | htmlCode | File | HTML code of the screen. | | figmaExport | File | Figma export of the screen. | | theme | DesignTheme | Theme used for generation. | | deviceType | DeviceType | Device type. | | screenType | ScreenType | Screen type. | | screenMetadata | ScreenMetadata | Metadata (agent, status, display mode). | | width | string | Width of the screen. | | height | string | Height of the screen. | | groupId | string | Group id for related screens (e.g., variants). | | groupName | string | Display name of the group. | | generatedBy | string | Generator identifier. | | isCreatedByClient | boolean | true if created via API upload, false if by agents. | #### File Section titled “File” | Field | Type | Description | | --- | --- | --- | | name | string | Resource name. Format: projects/{project}/files/{file} | | downloadUrl | string | URL for download. FIFE base URL for images. | | mimeType | string | E.g., "image/png", "text/html". | | fileContentBase64 | string | (Write-only) Base64-encoded content for uploads. | | uploadBlobId | string | BlobId from upload service. | | userFeedback | UserFeedback | (Read-only) Latest feedback. | #### DesignSystem Section titled “DesignSystem” Represents visual/functional design guidelines used to generate consistent, branded designs. | Field | Type | Description | | --- | --- | --- | | displayName | string | Display name of the design system. | | theme | DesignTheme | Theme configuration. | #### Asset Section titled “Asset” Wrapper for design system resources (used by `update_design_system`). | Field | Type | Description | | --- | --- | --- | | name | string | Resource name. Format: assets/{asset} | | designSystem | DesignSystem | The design system content. | | version | string | (Read-only) Version counter. 0 = unversioned. | #### DesignTheme Section titled “DesignTheme” | Field | Type | Required | Description | | --- | --- | --- | --- | | colorMode | ColorMode | true | Light or dark mode. | | headlineFont | Font | true | Headline typography. | | bodyFont | Font | true | Body typography. | | labelFont | Font | false | Label typography. | | roundness | Roundness | true | Corner roundness. | | customColor | string | true | Seed color for dynamic color system (hex, e.g., "#ff0000"). | | colorVariant | ColorVariant | false | Dynamic color system variant. | | overridePrimaryColor | string | false | Override primary color (hex). | | overrideSecondaryColor | string | false | Override secondary color (hex). | | overrideTertiaryColor | string | false | Override tertiary color (hex). | | overrideNeutralColor | string | false | Override neutral color (hex). | | designMd | string | false | Markdown design instructions. | #### ScreenMetadata Section titled “ScreenMetadata” | Field | Type | Description | | --- | --- | --- | | agentType | AgentTypeEnum | TURBO_AGENT, PRO_AGENT, IMAGE_AGENT, GENIE_AGENT, IMAGE_PRO_AGENT, HATTER_AGENT, GEMINI_3_AGENT | | status | ScreenStatusEnum | IN_PROGRESS, COMPLETE, FAILED | | statusMessage | string | Human-readable status from agent. | | displayMode | DisplayModeEnum | SCREENSHOT, HTML, CODE, MARKDOWN, STICKY_NOTE | | isRemixed | boolean | Whether screen was created from a remix. | | componentRegions | ComponentRegion[] | Component region annotations. | #### SessionOutputComponent Section titled “SessionOutputComponent” Returned from generation tools in `output_components`. | Field | Type | Description | | --- | --- | --- | | text | string | Agent text response. | | suggestion | string | Suggested follow-up for the user. | | design | Design | Generated design reference. | #### UserFeedback Section titled “UserFeedback” | Field | Type | Description | | --- | --- | --- | | rating | string | POSITIVE or NEGATIVE. | | comment | string | Additional comment. | | designFeedbackReason | string | DESIGN_DOESNT_MATCH_PROMPT, EDIT_DOESNT_MATCH_PROMPT, COMPONENT_ISSUE, INCORRECT_THEME, etc. | #### VariantOptions Section titled “VariantOptions” | Field | Type | Description | | --- | --- | --- | | variantCount | integer | Variants to generate (1–5). Default: 3. | | creativeRange | CreativeRange | Creative freedom level. | | aspects | VariantAspect[] | Aspects to focus on. | #### SelectedScreenInstance Section titled “SelectedScreenInstance” Used by `apply_design_system`. | Field | Type | Required | Description | | --- | --- | --- | --- | | id | string | true | Screen instance ID (from get_project), not the source screen ID. | | sourceScreen | string | true | Resource name. Format: projects/{project}/screens/{screen} | ### Enums Section titled “Enums” #### DeviceType Enum Section titled “DeviceType Enum” | Value | Description | | --- | --- | | DEVICE_TYPE_UNSPECIFIED | Unspecified. | | MOBILE | Mobile device. | | DESKTOP | Desktop device. | | TABLET | Tablet device. | | AGNOSTIC | Not tied to a device. | #### ModelId Enum Section titled “ModelId Enum” | Value | Description | | --- | --- | | MODEL_ID_UNSPECIFIED | Unspecified. | | GEMINI_3_PRO | (Deprecated) Gemini 3 Pro. Use GEMINI_3_1_PRO or GEMINI_3_FLASH instead. | | GEMINI_3_FLASH | Gemini 3 Flash. | | GEMINI_3_1_PRO | Gemini 3.1 Pro. | #### ScreenType Enum Section titled “ScreenType Enum” | Value | Description | | --- | --- | | SCREEN_TYPE_UNSPECIFIED | Defaults to DESIGN. | | DESIGN | A design screen. | | IMAGE | A pure image. | | PROTOTYPE | A design prototype. | | DOCUMENT | A document (e.g., PRD). | | PROTOTYPE_V2 | A design prototype v2. | #### ColorMode Enum Section titled “ColorMode Enum” | Value | Description | | --- | --- | | COLOR_MODE_UNSPECIFIED | Unspecified. | | LIGHT | Light mode. | | DARK | Dark mode. | #### ColorVariant Enum Section titled “ColorVariant Enum” | Value | Description | | --- | --- | | COLOR_VARIANT_UNSPECIFIED | Unspecified. | | MONOCHROME | Monochrome variant. | | NEUTRAL | Neutral variant. | | TONAL_SPOT | Tonal spot variant. | | VIBRANT | Vibrant variant. | | EXPRESSIVE | Expressive variant. | | FIDELITY | Fidelity variant. | | CONTENT | Content variant. | | RAINBOW | Rainbow variant. | | FRUIT_SALAD | Fruit salad variant. | #### Font Enum Section titled “Font Enum” 29 supported font families: `INTER` · `DM_SANS` · `GEIST` · `SORA` · `MANROPE` · `LEXEND` · `EPILOGUE` · `BE_VIETNAM_PRO` · `PLUS_JAKARTA_SANS` · `PUBLIC_SANS` · `SPACE_GROTESK` · `SPLINE_SANS` · `WORK_SANS` · `MONTSERRAT` · `METROPOLIS` · `SOURCE_SANS_THREE` · `NUNITO_SANS` · `ARIMO` · `HANKEN_GROTESK` · `RUBIK` · `IBM_PLEX_SANS` · `NEWSREADER` · `NOTO_SERIF` · `DOMINE` · `LIBRE_CASLON_TEXT` · `EB_GARAMOND` · `LITERATA` · `SOURCE_SERIF_FOUR` #### Roundness Enum Section titled “Roundness Enum” | Value | Description | | --- | --- | | ROUNDNESS_UNSPECIFIED | Unspecified. | | ROUND_TWO | (Deprecated) Round 2. | | ROUND_FOUR | Round 4. | | ROUND_EIGHT | Round 8. | | ROUND_TWELVE | Round 12. | | ROUND_FULL | Fully rounded. | #### CreativeRange Enum Section titled “CreativeRange Enum” | Value | Description | | --- | --- | | CREATIVE_RANGE_UNSPECIFIED | Unspecified. | | REFINE | Subtle refinements, close to original. | | EXPLORE | Balanced exploration. (Default) | | REIMAGINE | Radical explorations. | #### VariantAspect Enum Section titled “VariantAspect Enum” | Value | Description | | --- | --- | | VARIANT_ASPECT_UNSPECIFIED | Unspecified. | | LAYOUT | Element arrangement. | | COLOR_SCHEME | Color palette. | | IMAGES | Image usage. | | TEXT_FONT | Font choices. | | TEXT_CONTENT | Text content. | ### MCP Annotations Section titled “MCP Annotations” MCP Annotations are metadata hints that an MCP server attaches to each tool definition to tell the client (the AI agent or host application) about the tool’s behavioral characteristics. They’re part of the [MCP spec](https://modelcontextprotocol.io/specification/2025-06-18/server/tools#data-types) and help clients make smarter decisions about tool usage without needing to understand the tool’s implementation. Each tool includes behavior annotations: | Annotation | Meaning | | --- | --- | | readOnlyHint | true = read-only, no mutations. | | destructiveHint | true = may create/modify/delete resources. | | idempotentHint | true = repeated calls produce same result. | | openWorldHint | true = interacts with external systems. | #### How they work with tools in practice Section titled “How they work with tools in practice” Each tool in the Stitch MCP server declares these as part of its tool registration. For example: - `list_projects` has `readOnlyHint: true` — it just fetches data, so an agent can call it without worrying about side effects. - `create_project` has `readOnlyHint: false`, `destructiveHint: true`, `idempotentHint: false` — it mutates state, so the client should confirm with the user first. - `generate_screen_from_text` has `destructiveHint: true` and `idempotentHint: false` — each call creates a new screen, so retrying on a timeout could produce duplicates. #### Why they matter Section titled “Why they matter” These are hints, not enforced rules. They allow MCP clients to: - Auto-approve read-only tools without prompting the user - Show confirmation dialogs for destructive operations - Safely retry idempotent tools on network failures - Audit external interactions when `openWorldHint` is true In the Stitch server’s case, all tools have `openWorldHint: false` because they interact only with the Stitch backend — not arbitrary third-party services. ## Build your first design Source: https://stitch.withgoogle.com/docs/sdk/tutorial/ Install the Stitch SDK and generate your first UI screen in under five minutes. The Stitch SDK (`@google/stitch-sdk`) lets you generate, edit, and manage UI designs directly from TypeScript. No MCP config files, no CLI setup-just `npm install` and go. By the end of this tutorial, you’ll have a working script that creates a project, generates a screen, and retrieves the HTML and image URLs. google-labs-code / stitch-sdk Star TypeScript SDK for the Stitch design generation API TypeScript @google/stitch-sdk ### What you’ll need Section titled “What you’ll need” - **Node.js** 20 or later (or [Bun](https://bun.sh/)) - A **Stitch API Key** from your [Stitch Settings page](https://stitch.withgoogle.com/docs/mcp/setup) ### Install the SDK Section titled “Install the SDK” #### npm Section titled “npm” ``` npm install @google/stitch-sdk ``` #### Bun Section titled “Bun” ``` bun add @google/stitch-sdk ``` ### Set your API key Section titled “Set your API key” Export your key as an environment variable. The SDK picks it up automatically. ``` export STITCH_API_KEY="your-api-key" ``` ### Write the script Section titled “Write the script” Create a file called `my-first-design.ts`: ``` import { stitch } from "@google/stitch-sdk"; // 1. Create a project const project = await stitch.createProject("My First App"); console.log(`Project created: ${project.id}`); // 2. Generate a screen const screen = await project.generate("A simple login page with email and password fields"); console.log(`Screen generated: ${screen.id}`); // 3. Get your outputs const htmlUrl = await screen.getHtml(); const imageUrl = await screen.getImage(); console.log(`HTML: ${htmlUrl}`); console.log(`Image: ${imageUrl}`); ``` ### Run it Section titled “Run it” #### tsx Section titled “tsx” ``` npx tsx my-first-design.ts ``` #### Bun Section titled “Bun” ``` bun my-first-design.ts ``` You’ll see output that looks like this: ``` Project created: 4044680601076201931 Screen generated: 98b50e2ddc9943efb387052637738f61 HTML: https://... Image: https://... ``` Open the HTML URL in your browser. You’ll see a fully styled login page with Tailwind CSS baked in. ### What just happened? Section titled “What just happened?” You used three core SDK concepts: 1. **`stitch`** - The default singleton. It connects to the Stitch MCP server using your API key. 2. **`project.generate(prompt)`** - Sends a prompt to Stitch and returns a `Screen` object. 3. **`screen.getHtml()` / `screen.getImage()`** - Retrieves download URLs for the generated design. The SDK gives you a fluent, object-oriented API: `stitch` → `Project` → `Screen`. Each object knows how to navigate to the next. ### Next steps Section titled “Next steps” Now that you have a working design, try these: - [Edit a screen](https://stitch.withgoogle.com/docs/sdk/edit-screen) to refine the design with a follow-up prompt - [Generate variants](https://stitch.withgoogle.com/docs/sdk/generate-variants) to explore alternative layouts and color schemes - [Manage design systems](https://stitch.withgoogle.com/docs/sdk/design-systems) to create and apply visual themes across screens - [Upload files](https://stitch.withgoogle.com/docs/sdk/upload-image) to import mockups, screenshots, and HTML prototypes from disk - [Use the SDK with the Vercel AI SDK](https://stitch.withgoogle.com/docs/sdk/ai-sdk) to let an LLM orchestrate your design workflow - [Build agent-driven workflows](https://stitch.withgoogle.com/docs/sdk/agent-workflows) using `callTool` and `listTools` for full programmatic control - Check out the full [SDK Reference](https://stitch.withgoogle.com/docs/sdk/reference) for every method available ## Use with AI SDK Source: https://stitch.withgoogle.com/docs/sdk/ai-sdk/ Wire Stitch tools into the Vercel AI SDK and let an LLM generate designs autonomously. The Stitch SDK ships a dedicated adapter for the [Vercel AI SDK](https://sdk.vercel.ai/). Import `stitchTools()` from the `/ai` subpath and drop it directly into `generateText()` or `streamText()`. The LLM handles tool orchestration-you just write the prompt. ### Install Section titled “Install” You need three packages: ``` npm install @google/stitch-sdk ai @ai-sdk/google ``` ### Set your keys Section titled “Set your keys” ``` export STITCH_API_KEY="your-stitch-api-key" export GOOGLE_GENERATIVE_AI_API_KEY="your-gemini-api-key" ``` ### Basic usage Section titled “Basic usage” ``` import { generateText } from "ai"; import { google } from "@ai-sdk/google"; import { stitchTools } from "@google/stitch-sdk/ai"; const { text } = await generateText({ model: google("gemini-3.1-flash-lite-preview"), tools: stitchTools(), maxSteps: 5, prompt: "Create a new Stitch project called 'Landing Page' and generate a hero section with a CTA button.", }); console.log(text); ``` The LLM will call `create_project`, then `generate_screen_from_text`, then return a natural language summary of what it built. You don’t need to write any orchestration logic. ### Filter tools Section titled “Filter tools” If you want to restrict which tools the model can access, pass an `include` array: ``` const tools = stitchTools({ include: ["create_project", "generate_screen_from_text", "list_projects"], }); ``` This is useful for tightening the model’s scope-for example, preventing it from deleting projects. ### Override the API key Section titled “Override the API key” If you don’t want to rely on the `STITCH_API_KEY` env var, pass it directly: ``` const tools = stitchTools({ apiKey: "your-key-here" }); ``` ### How it works Section titled “How it works” `stitchTools()` returns a `Record` that is directly compatible with the AI SDK’s tool format. Each tool is pre-wired with an `execute` function that calls the underlying Stitch MCP server. The adapter has **zero runtime dependency** on the `ai` package-it only imports the `Tool` type. For a deeper look at the architecture, see [Architecture](https://stitch.withgoogle.com/docs/sdk/architecture). ## Agent-driven workflows Source: https://stitch.withgoogle.com/docs/sdk/agent-workflows/ Use callTool and listTools for full programmatic control over Stitch from AI agents and automation scripts. The domain API (`stitch.projects()`, `project.generate()`) is the preferred interface for humans writing scripts. But if you’re building an **AI agent**, an **automation pipeline**, or need access to tools the domain layer doesn’t wrap yet, use the lower-level `callTool` and `listTools` APIs. ### List available tools Section titled “List available tools” Discover what the Stitch MCP server can do: ``` import { stitch } from "@google/stitch-sdk"; const { tools } = await stitch.listTools(); for (const tool of tools) { console.log(`${tool.name}: ${tool.description}`); } ``` ### Call any tool by name Section titled “Call any tool by name” `callTool` gives you raw access to every MCP tool, including ones not yet surfaced in the domain API: ``` // Create a project const result = await stitch.callTool("create_project", { title: "Agent Project" }); console.log(result); // Generate a screen const screen = await stitch.callTool("generate_screen_from_text", { projectId: result.name.replace("projects/", ""), prompt: "A dashboard with charts and KPIs", }); console.log(screen); ``` ### How agents discover tool schemas Section titled “How agents discover tool schemas” An agent calling `callTool` needs to know two things: what parameters a tool expects, and what the response looks like. The SDK provides two ways to get this information. #### Runtime discovery with listTools() Section titled “Runtime discovery with listTools()” Call `listTools()` to get the full catalog of tools with their JSON Schemas. An agent reads these schemas to understand what arguments to construct: ``` const { tools } = await stitch.listTools(); const createTool = tools.find(t => t.name === "create_project"); console.log(JSON.stringify(createTool.inputSchema, null, 2)); // → { type: "object", properties: { title: { type: "string", ... } } } ``` The agent can then construct a valid `callTool` invocation from the schema - no hardcoded knowledge of parameter names required. #### Static schemas with toolDefinitions Section titled “Static schemas with toolDefinitions” The SDK also ships a **generated** `toolDefinitions` array (from `tools-manifest.json`) with the same schemas baked in at build time. This is what `stitchTools()` uses to wire tools into the Vercel AI SDK without a runtime `listTools()` call: ``` import { toolDefinitions } from "@google/stitch-sdk/tool-definitions"; // internal for (const tool of toolDefinitions) { console.log(tool.name, Object.keys(tool.inputSchema.properties)); } ``` #### Responses are unstructured Section titled “Responses are unstructured” `callTool` returns raw JSON from the MCP server - the shape depends on the tool. Agents should inspect the response dynamically rather than assuming a fixed structure. The domain API (`project.generate()`, `screen.edit()`) parses these responses into typed objects, but at the `callTool` level, it’s the agent’s job to interpret the result. ### Mix domain and tool APIs Section titled “Mix domain and tool APIs” The `stitch` singleton exposes both layers through the same object. You can use `callTool` for creation, then switch to the domain API for everything else: ``` // Create via callTool (agent-style) const raw = await stitch.callTool("create_project", { title: "Hybrid Flow" }); // Switch to domain API (human-style) const project = stitch.project(raw.name); const screen = await project.generate("A settings page"); const html = await screen.getHtml(); ``` This is the **identity map pattern** - `stitch.project(id)` creates a `Project` handle from any project ID or resource name without an API call. Use it to bridge between raw tool results and the fluent domain API. ### Build a custom client Section titled “Build a custom client” If you need OAuth credentials or want to connect to a different Stitch environment, instantiate `StitchToolClient` directly: ``` import { StitchToolClient } from "@google/stitch-sdk"; const client = new StitchToolClient({ accessToken: process.env.STITCH_ACCESS_TOKEN, projectId: process.env.GOOGLE_CLOUD_PROJECT, }); await client.connect(); const tools = await client.listTools(); console.log(`${tools.tools.length} tools available`); await client.close(); ``` ### When to use which Section titled “When to use which” | Pattern | Best for | | --- | --- | | Domain API (stitch.projects() → project.generate() → screen.getHtml()) | Human scripts, tutorials, straightforward workflows | | callTool | AI agents, automation, tools not in the domain layer, dynamic tool selection | | stitchTools() | Vercel AI SDK integration - see Use with AI SDK | | Custom StitchToolClient | OAuth, multi-tenant, or non-default server environments | ## How to edit a screen Source: https://stitch.withgoogle.com/docs/sdk/edit-screen/ Refine an existing design with a follow-up prompt using the SDK. Already have a screen? Use `screen.edit()` to iterate on it with natural language. The SDK handles the tool call, returns a new `Screen` object, and keeps the original untouched. ### Find a screen to edit Section titled “Find a screen to edit” First, grab a screen from one of your existing projects: ``` import { stitch } from "@google/stitch-sdk"; const projects = await stitch.projects(); const project = projects.at(0); const screens = await project.screens(); const screen = screens.at(0); console.log(`Editing screen ${screen.id} in project ${project.id}`); ``` ### Edit it Section titled “Edit it” Pass a natural language instruction to `screen.edit()`: ``` const edited = await screen.edit("Change the color scheme to dark mode"); ``` This returns a **new** `Screen` object. The original `screen` is unchanged. > Generation can take up to a minute. Don’t retry on timeout-the server is still working. ### Compare the results Section titled “Compare the results” ``` const originalHtml = await screen.getHtml(); const editedHtml = await edited.getHtml(); console.log(`Original: ${originalHtml}`); console.log(`Edited: ${editedHtml}`); ``` ### Specify a device type or model Section titled “Specify a device type or model” If you need a specific device target or model, pass them as optional parameters: ``` const edited = await screen.edit( "Add a bottom navigation bar", "MOBILE", // deviceType "GEMINI_3_PRO" // modelId ); ``` See the [Reference](https://stitch.withgoogle.com/docs/sdk/reference) for all available `deviceType` and `modelId` values. ## How to generate variants Source: https://stitch.withgoogle.com/docs/sdk/generate-variants/ Explore alternative designs by generating variants of an existing screen. Variants let you explore different takes on an existing design. Give the SDK a screen, a prompt, and some options-it returns an array of new `Screen` objects, each a unique riff on the original. ### Find a screen Section titled “Find a screen” ``` import { stitch } from "@google/stitch-sdk"; const projects = await stitch.projects(); const project = projects.at(0); const screens = await project.screens(); const screen = screens.at(0); ``` ### Generate variants Section titled “Generate variants” ``` const variants = await screen.variants( "Change the button style to outline", { numVariants: 3 } ); console.log(`Generated ${variants.length} variants`); ``` ### Browse the results Section titled “Browse the results” Each variant is a full `Screen` object with its own HTML and image: ``` for (const variant of variants) { const html = await variant.getHtml(); console.log(`Variant ${variant.id}: ${html}`); } ``` ### Variant options Section titled “Variant options” The second argument controls the generation behavior: ``` const variants = await screen.variants( "Explore different color palettes", { numVariants: 5, creativeRange: "REIMAGINE", aspects: ["COLOR_SCHEME", "LAYOUT"], } ); ``` | Option | Values | Description | | --- | --- | --- | | numVariants | 1–5 | Number of variants to generate. Default: 3. | | creativeRange | REFINE, EXPLORE, REIMAGINE | How far from the original. REFINE = subtle tweaks, REIMAGINE = radical changes. | | aspects | LAYOUT, COLOR_SCHEME, IMAGES, TEXT_FONT, TEXT_CONTENT | Which design aspects to vary. | See the [Reference](https://stitch.withgoogle.com/docs/sdk/reference) for the complete type definitions. ## How to download artifacts Source: https://stitch.withgoogle.com/docs/sdk/download-artifacts/ Save generated HTML and images to disk from the SDK. Every Stitch screen produces two downloadable artifacts: an **HTML file** (a complete document with inline Tailwind CSS) and a **screenshot image**. The SDK gives you download URLs-you just fetch and save. ### Get the download URLs Section titled “Get the download URLs” ``` import { stitch } from "@google/stitch-sdk"; const projects = await stitch.projects(); const screens = await projects.at(0).screens(); const screen = screens.at(0); const htmlUrl = await screen.getHtml(); const imageUrl = await screen.getImage(); ``` ### Save HTML to disk Section titled “Save HTML to disk” ``` import fs from "fs/promises"; const response = await fetch(htmlUrl); const html = await response.text(); await fs.writeFile(`${screen.id}.html`, html); ``` Open the file in a browser. You’ll see the fully rendered design with Tailwind classes. ### Save the screenshot image Section titled “Save the screenshot image” Images come back as binary data. Use `arrayBuffer()` instead of `text()`: ``` const imgResponse = await fetch(imageUrl); const buffer = await imgResponse.arrayBuffer(); await fs.writeFile(`${screen.id}.jpeg`, Buffer.from(buffer)); ``` ### Batch download all screens in a project Section titled “Batch download all screens in a project” ``` import fs from "fs/promises"; import path from "path"; const outDir = "./designs"; await fs.mkdir(outDir, { recursive: true }); const project = (await stitch.projects()).at(0); const screens = await project.screens(); for (const screen of screens) { const htmlUrl = await screen.getHtml(); if (htmlUrl) { const res = await fetch(htmlUrl); await fs.writeFile(path.join(outDir, `${screen.id}.html`), await res.text()); } const imgUrl = await screen.getImage(); if (imgUrl) { const res = await fetch(imgUrl); await fs.writeFile(path.join(outDir, `${screen.id}.jpeg`), Buffer.from(await res.arrayBuffer())); } } console.log(`Downloaded ${screens.length} screens to ${outDir}`); ``` ## How to extract themes Source: https://stitch.withgoogle.com/docs/sdk/extract-themes/ Parse Tailwind config, Google Fonts, and Material Symbols from generated HTML. Every Stitch screen generates a complete HTML document with an embedded Tailwind CSS configuration, Google Fonts links, and Material Symbols references. You can extract these to reuse the design system in your own project. ### Fetch the raw HTML Section titled “Fetch the raw HTML” Start by getting the HTML content from a screen: ``` import { stitch } from "@google/stitch-sdk"; const project = (await stitch.projects()).at(0); const screen = (await project.screens()).at(0); const htmlUrl = await screen.getHtml(); const response = await fetch(htmlUrl); const html = await response.text(); ``` ### Extract the Tailwind config Section titled “Extract the Tailwind config” Stitch embeds the Tailwind configuration in a `