> ## Documentation Index
> Fetch the complete documentation index at: https://flowstep.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Examples

> End-to-end workflows for common Flowstep MCP tasks.

## 1. Generate and preview a screen

The most common workflow: generate a screen (creating the file in the same step), then view the result.

```
1. list-files         {}
                      → { "files": [ ... ] }          // check for an existing file first

2. ai-design-screens  { "message": "Mobile sign-in screen for a developer tool.
                                    Email/password fields, Google SSO button, dark theme." }
                      → { "status": "generated", "fileId": "FILE_ID", "screenIds": ["SCREEN_ID"] }

3. get-screen-image   { "fileId": "FILE_ID", "screenId": "SCREEN_ID" }
                      → [inline PNG]
```

Omitting `fileId` creates a new file automatically. Pass an existing `fileId` to add screens to that file instead.

**Prompt to your AI assistant:**

> Generate a Flowstep design: a mobile sign-in screen for a developer tool with email/password and a Google SSO button in dark theme, then show me the image.

***

## 2. Visualize a React component

Upload a `.jsx` or `.tsx` file as an attachment and ask Flowstep to generate a matching design. Flowstep reads the source and produces a screen — no need to run the app.

```
1. upload-attachment  { "text": "<UTF-8 contents of ApiKeys.tsx>",
                        "mimeType": "text/javascript" }
                      → { "id": "ATT_ID", "path": "...", "assetUrl": "...", "type": "document",
                          "mimeType": "text/javascript" }

2. ai-design-screens  { "message": "Generate a desktop screen that matches this React component.",
                        "attachments": [{ "id": "ATT_ID", "path": "...", "type": "document" }] }
                      → { "status": "generated", "fileId": "FILE_ID", "screenIds": ["SCREEN_ID"], ... }

3. get-screen-image   { "fileId": "FILE_ID", "screenId": "SCREEN_ID" }
                      → [inline PNG]
```

For source files longer than 64,000 characters, use `upload-attachment` with `mimeType` and `fileName` instead and run the returned `uploadCommand`. See [`upload-attachment`](https://flowstep.ai/docs/mcp/tools.md#upload-attachment).

**Prompt to your AI assistant:**

> Read `src/components/settings/ApiKeys.tsx`, upload it as an attachment, and generate a Flowstep screen that matches the component layout. Show me the rendered image.

***

## 3. Iterate on a screen

Change an existing screen in place with free-form instructions — and, in the same call, add a new screen that matches it.

```
1. list-screens       { "fileId": "FILE_ID" }
                      → { "screens": [{ "screenId": "SCREEN_ID", "name": "Sign-in", ... }] }

2. ai-design-screens  { "fileId": "FILE_ID",
                        "message": "Edit this sign-in screen: switch it to dark mode and add a
                                    'Remember me' checkbox below the password field. Then add a
                                    matching forgot-password screen.",
                        "elementIds": ["SCREEN_ID"] }
                      → { "status": "generated", "fileId": "FILE_ID",
                          "screenIds": ["SCREEN_ID", "NEW_SCREEN_ID"], ... }

3. get-screen-image   { "fileId": "FILE_ID", "screenId": "SCREEN_ID" }
                      → [inline PNG]
   get-screen-image   { "fileId": "FILE_ID", "screenId": "NEW_SCREEN_ID" }
                      → [inline PNG]
```

`screenIds` lists every screen the call built or changed, so call `get-screen-image` once for each. Leave out the last sentence of the message to only edit the existing screen.

To change only part of a screen, call `get-screen-jsx` with `"includeIds": true` first and pass the `data-id` of the element you want to change in `elementIds`.

For a one-click preset on a whole screen, call `ai-edit-screen-variant` instead — for example `"operationVariant": "light_theme"` or `"different_layout"`.

**Prompt to your AI assistant:**

> In my “Login flow” Flowstep file, switch the sign-in screen to dark mode, add a “Remember me” checkbox below the password field, and add a matching forgot-password screen. Show me the results.

***

## 4. Expand a screen to a full flow

Add follow-on screens to an existing design.

```
1. list-screens                { "fileId": "FILE_ID" }
                               → { "screens": [{ "screenId": "BASE_SCREEN_ID", "prompt": "Sign-in screen", ... }] }

2. ai-generate-screen-variant  { "fileId": "FILE_ID",
                                 "screenId": "BASE_SCREEN_ID",
                                 "operationVariant": "next_screen" }
                               → { "status": "generated", "fileId": "FILE_ID", "screenIds": ["NEXT_SCREEN_ID"], ... }

3. get-screen-image            { "fileId": "FILE_ID", "screenId": "NEXT_SCREEN_ID" }
                               → [inline PNG]
```

Repeat step 2 with `operationVariant: "error_state"` or `"empty_state"` to add edge-case screens, or `"web_version"` / `"tablet_version"` for other platforms.

> [!NOTE]
>
> `operationVariant` is required for `ai-generate-screen-variant`, and the tool takes exactly one `screenId`. To add a screen that isn’t a variant of an existing one, use `ai-design-screens` with a `fileId`.

***

## 5. Hand a screen to your codebase, then write changes back

Read a screen as JSX, build from it, and push your edited JSX back to the canvas — all without using messages.

```
1. get-screen-jsx      { "fileId": "FILE_ID", "screenId": "SCREEN_ID" }
                       → { "name": "Settings", "fidelity": "ui", "screenType": "web",
                           "colorTheme": "default", "jsx": "<div ...>...</div>", "fragments": [] }

2. replace-screen-jsx  { "fileId": "FILE_ID", "screenId": "SCREEN_ID",
                         "jsx": "<div ...>...edited...</div>" }
                       → { "fileId": "FILE_ID", "screenId": "SCREEN_ID" }

3. get-screen-image    { "fileId": "FILE_ID", "screenId": "SCREEN_ID" }
                       → [inline PNG]
```

Omitted fields (`name`, `fidelity`, `screenType`, `colorTheme`, `fragments`) keep their current values. To keep the original and add your version alongside it, call `add-screen-jsx` with `screenType` and `jsx` instead of `replace-screen-jsx`.

To show your own image in the screen, upload it with `upload-attachment` and put the returned `assetUrl` in an `img src` in your JSX. See [Images in JSX](https://flowstep.ai/docs/mcp/tools.md#images-in-jsx).

***

## 6. Check your allowance before a batch job

Check remaining capacity before kicking off multiple generations. `get-plan-details` is free to call.

```
get-plan-details {}
→ { "plan": { ... }, "subscription": { ... }, "limits": { ... }, "usage": { ... },
    "remaining": { "messages": { "daily": ..., "monthly": ... } } }
```

If `remaining.messages.daily` is low, schedule the batch for after 00:00 UTC when it resets.
