$npx -y skills add google-labs-code/stitch-skills --skill upload-to-stitchUpload local assets (images, mockups, extracted HTML, design markdown) to a Stitch project. ALWAYS use this skill when you need to upload visual assets, HTML pages, or design docs to Stitch, particularly when direct MCP tool calls fail or truncate due to base64 token limits.
| 1 | # Upload-to-Stitch |
| 2 | |
| 3 | Upload local assets (images, mockups, HTML, and markdown files) to a Stitch project using the |
| 4 | provided upload script, which bypasses the MCP tool's base64 output token limits. |
| 5 | |
| 6 | > [!NOTE] |
| 7 | > The AI model cannot upload files via MCP tools directly because the base64 |
| 8 | > encoding of even a small file exceeds the model's output token limit (~16K |
| 9 | > tokens). This script reads the file and sends it directly over HTTP. |
| 10 | |
| 11 | ## Steps |
| 12 | |
| 13 | ### 1. Identify Target Project |
| 14 | |
| 15 | Use `list_projects` to find the correct `projectId`. |
| 16 | |
| 17 | ### 2. Get the API Key |
| 18 | |
| 19 | Locate your active MCP server configuration file and extract the API key: |
| 20 | - **Antigravity**: `.gemini/antigravity/mcp_config.json` or `.gemini/jetski/mcp_config.json` |
| 21 | - **Gemini CLI**: `~/.gemini/settings.json` or `~/.gemini/extensions/Stitch/gemini-extension.json` |
| 22 | - **Claude Code**: `~/.claude.json` |
| 23 | |
| 24 | Extract: |
| 25 | - **API Key**: From the `X-Goog-Api-Key` header or auth argument |
| 26 | - **MCP URL** (optional): From the `httpUrl` or endpoint argument (defaults to |
| 27 | `https://stitch.googleapis.com`) |
| 28 | |
| 29 | > [!IMPORTANT] |
| 30 | > If you cannot find the API key in any of these locations, or if you cannot access these files, you MUST ask the user to provide the Stitch API key. Do not proceed without a valid API key. |
| 31 | |
| 32 | ### 3. Run Upload Script |
| 33 | |
| 34 | > [!WARNING] |
| 35 | > **Checkpoint — User Confirmation Required.** |
| 36 | > Before running the upload script, you **MUST** pause and present the file(s) |
| 37 | > to be uploaded (paths, sizes, and types) to the user and wait for explicit |
| 38 | > approval. Do **NOT** execute the upload script until the user confirms. |
| 39 | |
| 40 | Use `run_command` to execute the Python script: |
| 41 | |
| 42 | ```bash |
| 43 | python3 <SKILL_DIR>/scripts/upload_to_stitch.py \ |
| 44 | --project-id <PROJECT_ID> \ |
| 45 | --file-path <PATH_TO_FILE> \ |
| 46 | --api-key <API_KEY> \ |
| 47 | [--api-url <STITCH_API_URL>] \ |
| 48 | [--title <SCREEN_TITLE>] \ |
| 49 | [--generated-by <GENERATED_BY>] |
| 50 | ``` |
| 51 | |
| 52 | > [!TIP] |
| 53 | > **macOS / SSL Certificate Troubleshooting:** |
| 54 | > If the upload fails with `ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] unable to get local issuer certificate`, this means your Python installation does not have root certificate authorities configured. |
| 55 | > |
| 56 | > The script automatically attempts to use the `certifi` package to load the CA bundle if it is installed in your python environment. If `certifi` is not installed, you can either install it (`pip install certifi`) or manually supply the `SSL_CERT_FILE` environment variable when running the script: |
| 57 | > ```bash |
| 58 | > SSL_CERT_FILE=$(python3 -c "import certifi; print(certifi.where())") python3 <SKILL_DIR>/scripts/upload_to_stitch.py \ |
| 59 | > --project-id <PROJECT_ID> \ |
| 60 | > --file-path <PATH_TO_FILE> \ |
| 61 | > --api-key <API_KEY> \ |
| 62 | > [--api-url <STITCH_API_URL>] \ |
| 63 | > [--title <SCREEN_TITLE>] \ |
| 64 | > [--generated-by <GENERATED_BY>] |
| 65 | > ``` |
| 66 | |
| 67 | ### Supported File Types |
| 68 | |
| 69 | | Extension | MIME Type | |
| 70 | |:---|:---| |
| 71 | | `.png` | `image/png` | |
| 72 | | `.jpg`, `.jpeg` | `image/jpeg` | |
| 73 | | `.webp` | `image/webp` | |
| 74 | | `.html`, `.htm` | `text/html` | |
| 75 | | `.md` | `text/markdown` | |
| 76 | |
| 77 | The script auto-detects MIME type from the file extension. |
| 78 | |
| 79 | ### Script Options |
| 80 | |
| 81 | - `--project-id`: **Required**. The Stitch project ID. |
| 82 | - `--file-path`: **Required**. Path to the local file to upload. |
| 83 | - `--api-key`: **Required**. API key for Stitch authorization. |
| 84 | - `--api-url`: Optional. Base URL of the Stitch API. Defaults to `https://stitch.googleapis.com`. |
| 85 | - `--title`: Optional. Title for the uploaded screen. |
| 86 | - `--generated-by`: Optional. Specify how the uploaded file was generated (e.g., 'stitch::extract-static-html' skill, 'Claude Code', 'Codex', 'Gemini' etc.). |