@_davideast/stitch-mcp

中文文档
0.9.0发布于 2026/05/29Apache-2.0TypeScriptES Module近 30 天下载 2.1万

Stitch MCP CLI helper. Automates Google Cloud authentication. Generates MCP config for your client. Sets up a proxy server.

原始使用文档
文档目录19 节
  1. Why
  2. Quick start
  3. Features
  4. MCP integration
  5. Virtual tools
  6. Explore your designs
  7. Installation
  8. Commands
  9. Authentication
  10. Environment variables
  11. Troubleshooting
  12. "Permission Denied" errors
  13. Authentication URL not appearing
  14. Already authenticated but showing logged in
  15. API connection fails after setup
  16. WSL / SSH / Docker environments
  17. Development
  18. License
  19. Disclaimer

stitch-mcp

A CLI for moving AI-generated UI designs into your development workflow — preview them locally, build sites from them, and feed them to coding agents.

Why

AI-generated designs in Google's Stitch platform live as HTML/CSS behind an API. Getting them into a local development environment — for previewing, building, or handing off to coding agents — requires fetching, serving, and structuring them. stitch-mcp handles this through a set of CLI commands that connect to Stitch.

Quick start

# Set up authentication and MCP client config
npx @_davideast/stitch-mcp init

# Serve all project screens on a local dev server
npx @_davideast/stitch-mcp serve -p <project-id>

# Build an Astro site by mapping screens to routes
npx @_davideast/stitch-mcp site -p <project-id>

Features

  • Preview designs locally — serve all screens from a project on a Vite dev server
  • Build an Astro site from your designs — map screens to routes and generate a deployable project
  • Give your agent design context — proxy Stitch tools to your IDE's coding agent with automatic token refresh
  • Explore your design data — browse projects, screens, and metadata in the terminal or via CLI
  • Browse projects in your terminal — navigate screens interactively with copy, preview, and open actions
  • Set up in one command — guided wizard handles gcloud, auth, and MCP client configuration

MCP integration

Add this to your MCP client config to give coding agents access to Stitch tools:

{
  "mcpServers": {
    "stitch": {
      "command": "npx",
      "args": ["@_davideast/stitch-mcp", "proxy"]
    }
  }
}

Supported clients: VS Code, Cursor, Claude Code, Gemini CLI, Codex, OpenCode.

Virtual tools

The proxy exposes these tools alongside the upstream Stitch MCP tools. They combine multiple API calls into higher-level operations for coding agents:

  • build_site — Builds a site from a project by mapping screens to routes. Returns the design HTML for each page.
  • get_screen_code — Retrieves a screen and downloads its HTML code content.
  • get_screen_image — Retrieves a screen and downloads its screenshot image as base64.

build_site input schema:

{
  "projectId": "string (required)",
  "routes": [
    {
      "screenId": "string (required)",
      "route": "string (required, e.g. \"/\" or \"/about\")"
    }
  ]
}

Example:

npx @_davideast/stitch-mcp tool build_site -d '{
  "projectId": "123456",
  "routes": [
    { "screenId": "abc", "route": "/" },
    { "screenId": "def", "route": "/about" }
  ]
}'

Explore your designs

Use view and tool to browse your design data and understand what's available before prompting agents.

# Browse all projects
npx @_davideast/stitch-mcp view --projects

# Inspect a specific screen
npx @_davideast/stitch-mcp view --project <project-id> --screen <screen-id>

# Invoke any MCP tool from the CLI
npx @_davideast/stitch-mcp tool [toolName]

Inside the view browser: c copies the selected value, s previews HTML in your browser, o opens the project in Stitch, and q quits. Use arrow keys to navigate and Enter to drill into nested data.

Run tool without a name to list all available tools, or with -s to see a tool's schema.


Installation

Run directly with npx (no install needed):

npx @_davideast/stitch-mcp <command>

Or install globally:

npm install -g @_davideast/stitch-mcp
stitch-mcp <command>

Commands

CommandDescription
Setup
initSet up auth, gcloud, and MCP client config
doctorVerify configuration health
logoutRevoke credentials
Development
serve -p <id>Preview project screens locally
screens -p <id>Browse screens in terminal
viewInteractive resource browser
Build
site -p <id>Generate Astro project from screens
snapshotSave screen state to file
Integration
tool [name]Invoke MCP tools from CLI
proxyRun MCP proxy for agents

Run any command with --help for full options.

Authentication

Automatic (recommended): Run init and follow the wizard. It handles gcloud installation, OAuth, credentials, and project setup.

npx @_davideast/stitch-mcp init

API key: Set the STITCH_API_KEY environment variable to skip OAuth entirely.

export STITCH_API_KEY="your-api-key"

Manual (existing gcloud): If you already have gcloud configured:

gcloud auth application-default login
gcloud config set project <PROJECT_ID>
gcloud beta services mcp enable stitch.googleapis.com --project=<PROJECT_ID>

Then use the proxy with STITCH_USE_SYSTEM_GCLOUD=1:

{
  "mcpServers": {
    "stitch": {
      "command": "npx",
      "args": ["@_davideast/stitch-mcp", "proxy"],
      "env": {
        "STITCH_USE_SYSTEM_GCLOUD": "1"
      }
    }
  }
}

Environment variables

VariableDescription
STITCH_API_KEYAPI key for direct authentication (skips OAuth)
STITCH_ACCESS_TOKENPre-existing access token
STITCH_USE_SYSTEM_GCLOUDUse system gcloud config instead of isolated config
STITCH_PROJECT_IDOverride project ID
GOOGLE_CLOUD_PROJECTAlternative project ID variable
STITCH_HOSTCustom Stitch API endpoint

Troubleshooting

"Permission Denied" errors

Ensure you have Owner or Editor role, billing is enabled, and the Stitch API is enabled. Run doctor --verbose to diagnose.

Authentication URL not appearing

The tool prints authentication URLs to the terminal with a 5-second timeout. Look for a URL starting with https://accounts.google.com. If using proxy with --debug, check /tmp/stitch-proxy-debug.log.

Already authenticated but showing logged in

The bundled gcloud SDK maintains separate authentication from your global gcloud installation. To fully clear authentication:

npx @_davideast/stitch-mcp logout --force --clear-config

API connection fails after setup

Run doctor --verbose to diagnose. Verify your project has billing and the Stitch API enabled. If issues persist, re-authenticate:

npx @_davideast/stitch-mcp logout --force
npx @_davideast/stitch-mcp init

WSL / SSH / Docker environments

The CLI detects WSL, SSH sessions, Docker containers, and Cloud Shell. In these environments, browser-based auth may not work automatically. Copy the OAuth URL from your terminal and open it in a browser manually.

Development

# Install dependencies
bun install

# Run locally
bun run dev init

# Run tests
bun test

# Build
bun run build

# Verify package
bun run verify-pack

License

Apache 2.0 © David East

Disclaimer

[!WARNING] Experimental Project - This is an independent, experimental tool.

This project is:

  • NOT affiliated with, endorsed by, or sponsored by Google LLC, Alphabet Inc., or the Stitch API team
  • Provided AS-IS with NO WARRANTIES of any kind
  • NOT guaranteed to be maintained, secure, or compatible with future API versions

"Stitch" and "Google Cloud" are trademarks of Google LLC.

USE AT YOUR OWN RISK.

版本与发布记录

@_davideast/stitch-mcp 共发布 25 个版本,首次发布于 2026/01/17;过去 12 个月发布了 25 个版本。

版本发布日期距今
0.9.0latest2026/05/295 个月前
0.8.02026/05/265 个月前
0.7.12026/05/135 个月前
0.7.02026/05/125 个月前
0.5.52026/04/276 个月前
0.5.32026/04/027 个月前

其他发布通道:next → 0.2.1。

关于 @_davideast/stitch-mcp 的常见问题

@_davideast/stitch-mcp 是什么?

Stitch MCP CLI helper. Automates Google Cloud authentication. Generates MCP config for your client. Sets up a proxy server.

如何安装 @_davideast/stitch-mcp?

在项目目录运行 npm install @_davideast/stitch-mcp,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 stitch-mcp,可以用 npx stitch-mcp 直接运行。

@_davideast/stitch-mcp 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@_davideast/stitch-mcp 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@_davideast/stitch-mcp 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@_davideast/stitch-mcp 可以商用吗?

@_davideast/stitch-mcp 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@_davideast/stitch-mcp 的下载量有多少?

根据 npm 官方下载统计,@_davideast/stitch-mcp 在 2026/10/05 – 2026/11/03 这 30 天内被下载 20,881 次,日均约 696 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@_davideast/stitch-mcp 还在维护吗?

最新版本 0.9.0 发布于 2026/05/29(5 个月前);至今共发布 25 个版本,其中过去 12 个月发布了 25 个;首次发布于 2026/01/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。