MCP Servers

A collection of Model Context Protocol servers, templates, tools and more.

S
Stitch MCP Integration

MCP server by alexmihai

Created 1/25/2026
Updated 3 days ago
Repository documentation and setup instructions

Stitch MCP Integration Package

A self-contained, reusable integration package for Google Stitch MCP (Model Context Protocol). This package provides automated setup, token management, and comprehensive tooling for integrating Stitch's UI design capabilities with Claude Code and other MCP clients.

Features

  • 🚀 Automated Setup - Interactive script handles authentication, API enablement, and configuration
  • 🔐 Dual Authentication - Supports both HTTP (token-based) and command-based (ADC) methods
  • 🔄 Token Management - Fast token refresh with backup and validation
  • 📦 Self-Contained - Copy to any project without modification
  • Robust - Includes validation, error handling, and backup creation
  • 📝 Well-Documented - Comprehensive guides and troubleshooting

What is Stitch MCP?

Google Stitch is a UI design tool integrated with Claude via the Model Context Protocol (MCP). It allows you to:

  • Generate UI mockups from text descriptions
  • Create design assets for web and mobile applications
  • Iterate on designs conversationally with Claude
  • Export designs to production-ready code

Quick Start

Prerequisites

  • gcloud CLI installed (Install guide)
  • Google Cloud Project with billing enabled
  • Node.js 20+ and npm

Installation

  1. Install dependencies:

    npm install chalk@^5.3.0 execa@^9.0.1 ora@^8.0.1 prompts@^2.4.2 ts-node@^10.9.2 @types/prompts@^2.4.9
    
  2. Add npm scripts to package.json:

    {
      "scripts": {
        "setup:stitch": "ts-node stitch-integration/scripts/setup.ts",
        "refresh:stitch-token": "ts-node stitch-integration/scripts/refresh-token.ts"
      }
    }
    
  3. Run setup:

    npm run setup:stitch
    

The setup script will guide you through:

  • Google Cloud authentication
  • Choosing authentication method (HTTP or command-based)
  • Enabling the Stitch API
  • Generating access tokens (if using HTTP)
  • Configuring .env.local and .mcp.json
  1. Restart your MCP client (Claude Code, IDE, etc.) to load the configuration

Usage

Token Refresh (HTTP Method Only)

Access tokens expire after ~1 hour. When your token expires, refresh it with:

npm run refresh:stitch-token

Then restart your MCP client to apply the new token.

Using Stitch with Claude

Once configured, you can use Stitch through Claude:

Generate a modern dashboard UI for a SaaS application
Create a mobile app login screen with social auth options

Claude will use the Stitch MCP server to generate designs and provide previews.

Authentication Methods

HTTP with Access Token (Recommended)

Pros:

  • ✅ More reliable connection
  • ✅ Easier to debug
  • ✅ Direct HTTP communication
  • ✅ Fast token refresh (~5 seconds)

Cons:

  • ⚠️ Token expires after ~1 hour (easily refreshed)

How it works:

  • Uses Application Default Credentials to generate access tokens
  • Connects directly to https://stitch.googleapis.com/mcp
  • Token stored in .env.local and .mcp.json

Command-based with ADC

Pros:

  • ✅ No token expiration
  • ✅ Uses standard Application Default Credentials

Cons:

  • ⚠️ May have connection issues
  • ⚠️ Harder to debug
  • ⚠️ Requires npx execution on each connection

How it works:

  • Spawns npx @google/genai-mcp-server command
  • Server uses Application Default Credentials
  • MCP client connects to local server process

Configuration Files

.env.local

GOOGLE_CLOUD_PROJECT=your-project-id
STITCH_AUTH_METHOD=http               # or 'command'
STITCH_ACCESS_TOKEN=ya29.a0...        # if http method

.mcp.json

Automatically configured by setup script. See templates/.mcp.json.example for manual configuration.

Scripts

setup.ts

Interactive setup wizard that:

  1. Validates prerequisites (gcloud CLI)
  2. Authenticates with Google Cloud
  3. Enables Stitch API
  4. Grants permissions
  5. Generates access tokens (HTTP method)
  6. Updates configuration files

Options:

  • --verbose - Show detailed output
  • --yes or -y - Auto-confirm all prompts

Example:

npm run setup:stitch -- --verbose

refresh-token.ts

Quickly refresh expired access token:

  1. Generates new token
  2. Validates token
  3. Updates .env.local and .mcp.json
  4. Creates backups

Options:

  • --verbose - Show detailed output

Example:

npm run refresh:stitch-token -- --verbose

Package Structure

stitch-integration/
├── README.md                # This file
├── SETUP.md                 # Integration guide for new projects
├── package.json             # Package metadata
├── tsconfig.json            # TypeScript configuration
├── .gitignore              # Git ignore rules
├── scripts/
│   ├── setup.ts            # Main setup script
│   ├── refresh-token.ts    # Token refresh utility
│   └── lib/
│       ├── env-manager.ts      # .env.local file management
│       ├── gcloud-auth.ts      # Google Cloud authentication
│       ├── mcp-config.ts       # .mcp.json configuration
│       ├── token-generator.ts  # Token generation & validation
│       └── validators.ts       # Prerequisite validation
├── docs/
│   └── troubleshooting.md  # Troubleshooting guide
├── templates/
│   ├── .env.example        # Environment template
│   └── .mcp.json.example   # MCP config examples
└── examples/
    ├── http-auth-example.md     # HTTP auth configuration
    └── command-auth-example.md  # Command auth configuration

Integrating into a New Project

See SETUP.md for detailed integration instructions.

Quick version:

  1. Copy entire stitch-integration/ folder to your project
  2. Install peer dependencies
  3. Add npm scripts to your package.json
  4. Run npm run setup:stitch

Troubleshooting

For common issues and solutions, see docs/troubleshooting.md.

Quick Fixes

  • Connection errors: npm run refresh:stitch-token (then restart client)
  • gcloud not found: Install from https://cloud.google.com/sdk/docs/install
  • API not enabled: Setup script enables it automatically
  • Permission denied: Setup script grants required roles

Dependencies

Peer Dependencies (required)

  • chalk@^5.3.0 - Terminal colors
  • execa@^9.0.1 - Process execution
  • ora@^8.0.1 - Loading spinners
  • prompts@^2.4.2 - Interactive prompts
  • ts-node@^10.9.2 - TypeScript execution
  • @types/prompts@^2.4.9 - Type definitions

System Dependencies

  • gcloud CLI
  • Node.js 20+
  • Active Google Cloud project with billing

Advanced Usage

Switching Authentication Methods

Run npm run setup:stitch and select a different method when prompted.

Multiple Projects

Run setup for each project, or manually update GOOGLE_CLOUD_PROJECT in .env.local.

Verbose Mode

For detailed debugging information:

npm run setup:stitch -- --verbose
npm run refresh:stitch-token -- --verbose

CI/CD Integration

For automated environments:

  1. Use service account credentials
  2. Set GOOGLE_APPLICATION_CREDENTIALS environment variable
  3. Use command-based method (no token refresh needed)

Security

  • .env.local is gitignored (never commit tokens)
  • ✅ Backups created before file modifications
  • ✅ Tokens masked in console output
  • ✅ Validation ensures tokens work before saving
  • ⚠️ Tokens expire after 1 hour (by design)

Support

License

MIT

Related Links

Quick Setup
Installation guide for this server

Install Package (if required)

npx @modelcontextprotocol/server-stitch-mcp-integration

Cursor configuration (mcp.json)

{ "mcpServers": { "alexmihai-stitch-mcp-integration": { "command": "npx", "args": [ "alexmihai-stitch-mcp-integration" ] } } }