google-labs-code/stitch-sdk
Generate UI screens from text prompts and extract their HTML and screenshots programmatically.
Platform-specific configuration:
{
"mcpServers": {
"stitch-sdk": {
"command": "npx",
"args": [
"-y",
"stitch-sdk"
]
}
}
}Add the config above to .claude/settings.json under the mcpServers key.
[](https://www.npmjs.com/package/@google/stitch-sdk)
Generate UI screens from text prompts and extract their HTML and screenshots programmatically.
Set your API key and generate a screen:
import { stitch } from "@google/stitch-sdk";
// STITCH_API_KEY must be set in the environment
const project = stitch.project("your-project-id");
const screen = await project.generate("A login page with email and password fields");
const html = await screen.getHtml();
const imageUrl = await screen.getImage();html is a download URL for the screen's HTML. imageUrl is a download URL for the screenshot.
Need to create a project first? Use the tool client:
const result = await stitch.callTool("create_project", { title: "My App" });npm install @google/stitch-sdkTo use stitchTools() with the Vercel AI SDK, install ai as well:
npm install @google/stitch-sdk aiimport { stitch } from "@google/stitch-sdk";
const projects = await stitch.projects();
for (const project of projects) {
console.log(project.id, project.projectId);
const screens = await project.screens();
console.log(` ${screens.length} screens`);
}If you already have a project ID, reference it directly:
const project = stitch.project("4044680601076201931");
// Call methods on it — each method fetches data as needed
const screens = await project.screens();const screen = await project.generate("A dashboard with charts");
const edited = await screen.edit("Make the background dark and add a sidebar");
const editedHtml = await edited.getHtml();const variants = await screen.variants("Try different color schemes", {
variantCount: 3,
creativeRange: Loading reviews...