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

# MCP 示例

> 常见 Flowstep MCP 任务的端到端工作流程。

## 1. 生成并预览屏幕

最常见的工作流：生成一个屏幕（同时创建文件），然后查看结果。

```
1. create-new-design { "message": "Mobile sign-in screen for a developer tool.
                                  Email/password fields, Google SSO button, dark theme." }
                     → { "fileId": "FILE_ID", "screenIds": ["SCREEN_ID"] }

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

省略 `fileId` 会自动创建一个新文件。传递现有的 `fileId` 可将屏幕添加到该文件。

**向您的 AI 助手提示：**

> 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. 可视化 React 组件

上传 `.jsx` 或 `.tsx` 文件作为附件，并请求 Flowstep 生成匹配的设计。Flowstep 读取源代码并生成屏幕 — 无需运行应用。

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

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

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

**向您的 AI 助手提示：**

> 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. 在 MCP 生成的屏幕上迭代

`edit-design` 和 `regenerate-design` 需要设计上下文，该上下文仅存在于使用 `designs` 数组生成的屏幕上。对于没有该数组的屏幕，解决方法是将屏幕呈现为附件并使用图像调用 `create-new-design`。

```
1. upload-attachment  { "fileId": "FILE_ID", "screenId": "SCREEN_ID" }
                      → { "id": "ATT_ID", "path": "...", "type": "image", "mimeType": "image/jpeg" }

2. create-new-design  { "fileId": "FILE_ID",
                        "message": "Change the color scheme to dark mode and
                                    add a 'Remember me' checkbox below the password field.",
                        "attachments": [{ "id": "ATT_ID", "path": "...", "type": "image" }] }
                      → { "fileId": "FILE_ID", "screenIds": ["NEW_SCREEN_ID"] }

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

对于具有设计上下文的屏幕，直接调用 `edit-design`，在 `message` 中包含变更，在 `targets` 中包含屏幕。

***

## 4. 将屏幕扩展为完整流程

向现有设计添加后续屏幕。

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

2. expand-design  { "fileId": "FILE_ID",
                    "message": "Add the next screen in the user flow",
                    "operationVariant": "next_screen",
                    "targets": ["BASE_SCREEN_ID"] }
                  → { "fileId": "FILE_ID", "screenIds": ["NEXT_SCREEN_ID"] }

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

重复第 2 步，使用 `operationVariant: "error_state"` 或 `"empty_state"` 来添加边界情况屏幕。

<Note>
  `operationVariant` 是 `expand-design` 的必需参数。基础屏幕也必须使用 `designs` 数组（设计上下文）生成 — 对于没有它的屏幕，请使用示例 3 中的附件解决方法。
</Note>

***

## 5. 批处理前审计配额

在启动多个生成之前检查剩余容量。

```
get-plan-details {}
→ {
    "remaining": {
      "messages": { "daily": 38, "monthly": 413 }
    }
  }
```

如果 `daily` 较低，请在 00:00 UTC 后（重置时）安排批处理。
