CLI for moving AI-generated UI designs from Google's Stitch platform into development workflows with local preview, site generation, and agent integration.
CLI for moving AI-generated UI designs from Google's Stitch platform into development workflows with local preview, site generation, and agent integration.
triggers
["preview my Stitch designs locally","build an Astro site from Stitch screens","set up Stitch MCP integration","serve Stitch project screens","connect Stitch designs to my coding agent","export Stitch UI to my project","browse Stitch designs in terminal","authenticate with Stitch API"]
Use the build_site tool to create a website from my Stitch project 123456.
Map screen abc123 to the home page, def456 to /about, and ghi789 to /contact.
get_screen_code
Retrieves a screen and downloads its HTML code content.
Use system gcloud config instead of isolated config
STITCH_PROJECT_ID
Override project ID
GOOGLE_CLOUD_PROJECT
Alternative project ID variable
STITCH_HOST
Custom Stitch API endpoint
Common Patterns
Pattern 1: Preview All Designs Before Building
# 1. Browse available screens
npx @_davideast/stitch-mcp screens -p <project-id>
# 2. Serve locally to review designs
npx @_davideast/stitch-mcp serve -p <project-id>
# 3. Build site after confirming screens
npx @_davideast/stitch-mcp site -p <project-id>
Pattern 2: Agent-Driven Site Generation
User prompt to agent:
I have a Stitch project with ID 123456. It has three screens:
- Home page (screen ID: abc123)
- About page (screen ID: def456)
- Contact page (screen ID: ghi789)
Use the build_site tool to generate HTML for all three pages with routes /, /about, and /contact.
Then help me integrate them into my Next.js project.
The agent will use build_site and can help integrate the resulting HTML.
Pattern 3: Iterative Design Review
# View specific screen details
npx @_davideast/stitch-mcp view --project <project-id> --screen <screen-id>
# Preview in browser (press 's' in interactive view)# Or manually:
npx @_davideast/stitch-mcp snapshot -p <project-id> -s <screen-id> -o ./preview.html
open ./preview.html
# Get the HTML code for integration
npx @_davideast/stitch-mcp tool get_screen_code -d '{
"projectId": "<project-id>",
"screenId": "<screen-id>"
}'
Pattern 4: Automated Site Builds in CI
#!/bin/bash# ci-build-stitch.shexport STITCH_API_KEY="${STITCH_API_KEY}"
PROJECT_ID="123456"# Generate site with predefined routes
npx @_davideast/stitch-mcp site -p "$PROJECT_ID" \
--config ./stitch-routes.json \
-o ./dist/stitch-site \
--non-interactive
# Deploy the generated sitecd ./dist/stitch-site
npm install
npm run build
Symptoms: Browser-based auth doesn't work automatically.
Solution: The CLI detects these environments. Copy the OAuth URL from terminal output and open it in a browser manually. The URL will be printed to stdout with clear instructions.
Symptoms:tool command returns errors or empty responses.
Solutions:
Check tool schema:
npx @_davideast/stitch-mcp tool <tool-name> -s
Validate JSON data:
echo'{"projectId":"123"}' | jq .
Test with simpler tool first:
npx @_davideast/stitch-mcp tool list_projects
Ensure project and screen IDs are correct:
npx @_davideast/stitch-mcp view --projects
Development & Testing
# Clone and install
git clone https://github.com/davideast/stitch-mcp.git
cd stitch-mcp
bun install
# Run locally
bun run dev init
# Run specific command
bun run dev serve -p <project-id>
# Run tests
bun test# Build
bun run build
# Verify package
bun run verify-pack
Real-World Agent Prompts
Example 1: Site Generation
I have a Stitch project (ID: 456789) with these screens:
- Landing page: screen_landing_001
- Features page: screen_features_002
- Pricing page: screen_pricing_003
Please use the build_site tool to generate a site with:
- Landing at /
- Features at /features
- Pricing at /pricing
Then show me how to integrate the HTML into my existing React project.
Example 2: Design Review
Get the HTML code for screen abc123 from project 456789 using get_screen_code.
Then analyze the CSS and suggest improvements for mobile responsiveness.
Example 3: Batch Export
For project 456789, use get_screen_image to export all screen screenshots as base64.
Save them to a design-assets/ directory for our design system documentation.