# pi Stitch MCP Extension

A pi package that bridges pi to the Google Stitch remote MCP server (`https://stitch.googleapis.com/mcp`). Stitch is Google's design-to-code platform — generate pixel-perfect Flutter, React (JSX), and SwiftUI components from Figma designs.

It exposes a small, generic bridge instead of registering dozens of Stitch tools by default. This keeps pi's tool list compact while still allowing the model to discover and call any Stitch MCP tool.

## Installation

```bash
pi install npm:@khmuhtadin/pi-stitch-mcp
```

## Prerequisites

You need a Google Stitch API key. Set it via:

```bash
export GOOGLE_STITCH_API_KEY="your-api-key-here"
```

Or inside pi:

```text
/stitch-mcp-set-key your-api-key-here
```

## Registered tools

- `stitch_mcp_list_tools` — list tools exposed by the Stitch MCP server.
- `stitch_mcp_call_tool` — call any Stitch MCP tool by `name` with JSON `arguments`.

## Slash commands

- `/stitch-mcp-set-key <key>` — set the Google Stitch API key in memory (not persisted across restarts; use `GOOGLE_STITCH_API_KEY` env var for persistence).
- `/stitch-mcp-register [tool1,tool2|*]` — optional: register selected MCP tools as native pi tools with a `stitch_` prefix.
- `/stitch-mcp-reset` — reset the connection.

## Configuration

Optional environment variables:

- `GOOGLE_STITCH_API_KEY` — your Google Stitch API key (recommended).
- `STITCH_MCP_URL` — defaults to `https://stitch.googleapis.com/mcp`.
- `STITCH_MCP_TIMEOUT_MS` — defaults to `30000`.

## Development

```bash
npm install
npm run typecheck
npm pack --dry-run
```

## License

MIT
