
# @refore-ai/html-to-pixso-china-mcp

Agent 按你的要求打开很多页面 / 浏览模块，比如一个操作流程 / 所有子模块，挨个通过这个 MCP 导入到
Pixso 的设计稿里。

MCP (Model Context Protocol) server，让 AI agent（Claude Code、Claude Desktop、Codex、Cursor、
Windsurf 等任意 MCP 客户端）通过 Pixso 里的 [Refore 网页转设计](https://pixso.cn/plugins/?id=jxlQCMwU753T0UJhz93xyg) 插件，把 HTML 文件和网页导入到
Pixso 画布。

## 环境要求

- Node.js 18+
- 已在 Pixso 安装 [Refore 网页转设计](https://pixso.cn/plugins/?id=jxlQCMwU753T0UJhz93xyg) 插件
  
## 配置

**Claude Code**

```bash
claude mcp add refore-html-to-pixso-china -- npx -y @refore-ai/html-to-pixso-china-mcp
```

**Claude Desktop** — 写入 `claude_desktop_config.json`，改完重启：

```json
{
  "mcpServers": {
    "refore-html-to-pixso-china": {
      "command": "npx",
      "args": ["-y", "@refore-ai/html-to-pixso-china-mcp"]
    }
  }
}
```

**Codex** — 写入 `~/.codex/config.toml`：

```toml
[mcp_servers.refore-html-to-pixso-china]
command = "npx"
args = ["-y", "@refore-ai/html-to-pixso-china-mcp"]
```

**Cursor / Windsurf / 其它** — 用与上面 Claude Desktop JSON 相同的 `command` / `args`。

然后在 Pixso 里打开 Refore 网页转设计 插件，进入 **MCP** tab 并连接，就可以让 agent
导入页面了。

## 工具

### 导入

| 工具                  | 用途                                                                                                                                                                                   |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `import_html`         | 首选导入入口：导入一段 HTML 内容或一个本地 `.html` 文件路径。路径模式带 `source`：`user-file`（你直接给 agent 的本地文件，直接导入、不需要浏览器和抓取指南）或 `browser-dump`（agent 从浏览器抓的 dump，首次导入前须读过指南）；缺省按文件位置猜。可选 `assets`（HTML 引用的本地文件）、`viewport`、`target`（插入到某节点下 / 替换某节点，replace 可用 `nodeId` 或上次导入的 `taskId` 定位）、`wait` |
| `dev_import_demo`     | **仅 `--dev`**：导入 Refore demo 分享链接（`app.demoway.cn|com/demo/<id>`），走插件内 capture 页，与用户手动打开该 demo 导入是同一条路径，因此能复现用户看到的结果。可选 `selector`、`target`、`wait`。仅支持单步 demo，且插件须为 dev 构建 |
| `no_browser_fallback` | agent 无论何种原因拿不到页面 DOM 时的兜底：先让用户在「插件按 URL 抓取导入 / 用浏览器插件录制导入」中二选一，用户选前者才按 URL 匿名抓取导入（服务端从插件版本对应区域抓取，有区域局限） |
| `get_capture_guide`   | 返回 DOM 抓取标准作业指南（抓取脚本 / 大体积回传通道策略 / 导入验证重导闭环），dump 前调用一次；只服务 dump 场景，直接给的本地文件不需要它                                              |
| `remove_import`       | 按 taskId 删除某次导入的产物（幂等；只认本连接的任务）                                                                                                                                 |
| `wait_task`           | 阻塞等一个任务落定，返回最终结果                                                                                                                                                       |
| `get_task_status`     | 非阻塞查询某个任务当前的 phase / 结果                                                                                                                                                  |
| `get_status`          | 返回 `ws_port` / `connected` / `queue { mine, total, running }`                                                                                                                        |

### 读画布

导入后自检用：找到落位的节点、核对几何、肉眼看一眼。

| 工具                  | 用途                                                                             |
| --------------------- | -------------------------------------------------------------------------------- |
| `get_design_context`  | 打开的是哪个文件、有哪些页面、当前在哪页                                         |
| `get_selection`       | 用户当前选中了什么                                                               |
| `query_nodes`         | 按名称/类型查找节点；只给 `root` 就是「列出该节点的直接子级」                    |
| `get_nodes`           | 按 id 读节点；`props` 可原样取任意平台原生属性                                   |
| `get_local_styles`    | 文件里的 paint / text / effect 样式表                                            |
| `get_available_fonts` | Pixso 里可用的字体，按字族分组                                     |
| `get_variables`       | 变量集与各模式下的变量值                                                         |
| `export_node_image`   | 渲染节点：PNG 或 SVG，尺寸走平台原生 `constraint`，`saveTo` 可直接落盘只回路径   |

### 导航

只改视图，不改文档。

| 工具               | 用途                         |
| ------------------ | ---------------------------- |
| `select_nodes`     | 只改选中状态，不动视口       |
| `scroll_into_view` | 只把视口移过去，不改选中状态 |
| `set_current_page` | 切换当前页                   |

本 MCP **刻意不提供任何修改文档的工具** —— 导入就是它唯一的写入路径。需要让 agent 直接改节点，
用 [`@refore-ai/talk-to-design-mcp`](https://www.npmjs.com/package/@refore-ai/talk-to-design-mcp)。
