docs(mcp,skills): prefer built-in browser OAuth and keep cookie-isolation guidance silent (#1102)

* docs(mcp,skills): prefer built-in browser OAuth and keep cookie-isolation guidance silent

* docs(mcp,skills): recommend --no-browser CLI OAuth for built-in browser hosts

---------

Co-authored-by: 罗高 <luogao@users.noreply.github.com>
This commit is contained in:
open-design-crew[bot]
2026-11-25 18:37:42 +08:00
committed by GitHub
parent 7dd2b09546
commit b057de669b
6 changed files with 57 additions and 13 deletions

View File

@@ -5,7 +5,7 @@ description: Guide cloud MCP login, open the template library, and show the welc
# OpenMotion onboarding
Follow the [shared cloud connection & onboarding contract](../../docs/install.md#installation-success-reply). Open the cloud template library once and deliver the maintained localized welcome with three curated template preview cards. Accept current-chat MCP tool activation independently; registration or a later connected chat does not prove tools hot-loaded in the current turn.
Follow the [shared cloud connection & onboarding contract](../../docs/install.md#installation-success-reply). If OAuth login is still required on a host with a built-in browser, prefer opening `authorizationUrl` in that built-in browser—via host OAuth RPC or `codex mcp login --no-browser openmotion` with stdin kept open so it suppresses the default system browser launch—(falling back to the system browser if unavailable or blocked) so editor tabs inherit the same session; keep built-in vs. system browser session isolation silent unless the user asks or encounters a sign-in/workspace gate. Open the cloud template library once and deliver the maintained localized welcome with three curated template preview cards. Accept current-chat MCP tool activation independently; registration or a later connected chat does not prove tools hot-loaded in the current turn.
1. **Use the cloud onboarding endpoint.** Derive `LANG` (`zh`, `en`, `ja`, `ko`, `fr`, `es`, `pt`, else `en`) from the user's latest request. Call `GET <ORIGIN>/api/onboarding/prepare?lang=<LANG>` once (default `<ORIGIN>` is `https://motion.open-design.ai`, or the explicit deployment origin) to freeze three distinct curated IDs/order, `libraryUrl`, localized welcome copy, `inlineHtmlUrl`, `inlineHtmlSha256`, and template metadata. Preserve those exact three IDs on retries by passing `&templates=id1,id2,id3`; never resample or substitute built-ins.
2. **Verify connection only as needed.** If `openmotion_get_project` is natively available in this chat, call it once (an empty project list is normal for a newly authorized OAuth client). If MCP registration + OAuth login just finished and this chat has not hot-loaded tools yet, report that refresh/new-chat step honestly without blocking onboarding or restarting the host.

View File

@@ -25,7 +25,7 @@ Use **only** the row matching the current host (skip if `openmotion` already poi
| Host | Add MCP server | Auth method |
| --- | --- | --- |
| **Codex** | `codex mcp add openmotion --url 'https://motion.open-design.ai/mcp'` | OAuth 2.1 (`codex mcp login openmotion` or host OAuth RPC) |
| **Codex** | `codex mcp add openmotion --url 'https://motion.open-design.ai/mcp'` | OAuth 2.1 (host OAuth RPC, `codex mcp login --no-browser openmotion`, or `codex mcp login openmotion`) |
| **Claude Code** | `claude mcp add --transport http --scope user openmotion 'https://motion.open-design.ai/mcp'` | OAuth 2.1 (`claude mcp login openmotion`) |
| **ChatGPT** | Settings → **Connectors** → **Add MCP Server** → `https://motion.open-design.ai/mcp` | OAuth 2.1 |
| **Claude.ai / Claude Desktop** | Settings → **Connectors** → **Add custom connector** → `https://motion.open-design.ai/mcp` | OAuth 2.1 |
@@ -39,21 +39,31 @@ Use **only** the row matching the current host (skip if `openmotion` already poi
1. **Skip login if already authorized**:
- In **Codex**, if `openmotion_get_project` already works or `codex mcp list --json` already reports `"auth_status": "o_auth"` for `openmotion` (pointing to `https://motion.open-design.ai/mcp`), skip login and go straight to Step 3.
- In **Claude Code**, run `claude mcp get openmotion` — if status is already **`Connected`**, skip login and go straight to Step 3.
2. **Run login and wait automatically (no manual "authorized" reply required)**:
- **Codex (Desktop / CLI)**: run `codex mcp login openmotion` directly in the shell with a generous timeout (`180–300s`). It automatically opens the user's browser and listens for the OAuth callback:
- Exit `0`: authorization succeeded — proceed immediately to Step 3 without asking the user to confirm.
- Non-zero exit (e.g., user clicked **Deny / 拒绝** or canceled): report briefly that authorization was not completed and stop.
- **Claude Code**: run `claude mcp login openmotion` directly with a generous timeout (`180–300s`). If the shell reports stdin is not a terminal, launch it inside a PTY and poll the log until authentication completes (if the browser did not open, share the printed authorization URL):
- macOS: `script -qF /tmp/openmotion-login.log claude mcp login openmotion < /dev/null > /dev/null 2>&1 &`
- Linux: `script -qfc "claude mcp login openmotion" /tmp/openmotion-login.log > /dev/null 2>&1 &`
- Once authenticated (`Authenticated with` / exit `0`), proceed immediately to Step 3. If denied/failed, report briefly and stop.
3. **Fallback ONLY when shell cannot open a browser or bind localhost (sandboxed / remote / headless)**:
- If the host exposes a non-blocking OAuth RPC (e.g. Codex Desktop `config/mcpServer/reload` + `mcpServer/oauth/login` with `{ "name": "openmotion", "timeoutSecs": 300 }`), call it to get `authorizationUrl`, send only the clickable link with a brief note to sign in / click **Allow / 同意授权** and reply when done (never mention onboarding, templates, or internal verification), and end your turn to wait.
2. **Run login (prefer the host's built-in browser when available)**:
- **Hosts with a built-in browser (e.g., Codex Desktop / CUA)**:
- **Prefer completing OAuth inside the host's built-in browser** (such as `open_in_codex` with `placement: "right"`, `target: { type: "browser", url: authorizationUrl }`, or CUA IAB) so the user signs in and approves access in the same browser that will later display the cloud editor:
1. When the host exposes an OAuth RPC returning `authorizationUrl` (such as Codex Desktop `config/mcpServer/reload` + `mcpServer/oauth/login` with `{ "name": "openmotion", "timeoutSecs": 300 }`), call it and **prefer opening `authorizationUrl` directly inside the host's built-in browser**.
2. Otherwise, when running CLI login on a host with a built-in browser, **prefer `codex mcp login --no-browser openmotion`** inside an interactive PTY / persistent shell with stdin kept open (do **not** close stdin with `< /dev/null`, or `--no-browser` exits before the callback arrives). It suppresses the default system browser launch, prints the authorization URL, and still listens on `http://127.0.0.1:<port>/callback` — capture the printed authorization URL and open it in the host's **built-in browser** (once the user approves, the loopback callback completes automatically without manual URL pasting; wait for exit `0`).
- Send only a brief prompt to sign in and click **Allow / 同意授权** (and share the clickable link if needed; never mention onboarding, templates, or internal verification), then wait for completion.
- If `--no-browser` is unsupported by the local CLI, the host cannot open the URL in a built-in browser, or sign-in/callback is blocked inside the built-in browser (for example, third-party OAuth restrictions or localhost callback blocking), fall back to running `codex mcp login openmotion` in the shell (timeout `180–300s`), which opens the user's system browser and listens for the callback:
- Exit `0`: authorization succeeded — proceed immediately to Step 3 without asking the user to confirm.
- Non-zero exit (e.g., user clicked **Deny / 拒绝** or canceled): report briefly that authorization was not completed and stop.
- **CLI hosts without a built-in browser (Codex CLI / Claude Code)**:
- **Codex CLI**: run `codex mcp login openmotion` directly in the shell with a generous timeout (`180–300s`). It automatically opens the user's system browser and listens for the OAuth callback (continue on exit `0`; report briefly and stop on non-zero exit).
- **Claude Code**: run `claude mcp login openmotion` directly with a generous timeout (`180–300s`). If the shell reports stdin is not a terminal, launch it inside a PTY and poll the log until authentication completes (if the browser did not open, share the printed authorization URL):
- macOS: `script -qF /tmp/openmotion-login.log claude mcp login openmotion < /dev/null > /dev/null 2>&1 &`
- Linux: `script -qfc "claude mcp login openmotion" /tmp/openmotion-login.log > /dev/null 2>&1 &`
- Once authenticated (`Authenticated with` / exit `0`), proceed immediately to Step 3. If denied/failed, report briefly and stop.
3. **Fallback when shell cannot open a browser or bind localhost (sandboxed / remote / headless)**:
- If the host exposes a non-blocking OAuth RPC (e.g. Codex Desktop `config/mcpServer/reload` + `mcpServer/oauth/login` with `{ "name": "openmotion", "timeoutSecs": 300 }`), call it to get `authorizationUrl`, open it in the built-in browser when available or send only the clickable link with a brief note to sign in / click **Allow / 同意授权** and reply when done (never mention onboarding, templates, or internal verification), and end your turn to wait.
- Otherwise, **stop** and tell the user in plain language (`LANG`) using **only** their host's single action:
1. Run `claude mcp login openmotion` / `codex mcp login openmotion` in their local terminal (add `--no-browser` over SSH; in Claude Code they can also use `/mcp` → `openmotion` → **Authenticate**; in GUI clients, click **Connect / Log in**).
2. Sign in to their OpenDesign account (skipped if already signed in) and click **Allow / 同意授权**.
3. Ask them to reply once authorized to continue (e.g., "授权完成后告诉我一声即可。" / "Let me know once you've authorized."). **Never** mention verification details, onboarding, template library, or recommended templates in this waiting message.
> **Silent browser-session context (do NOT mention proactively to the user):**
> A host's built-in browser uses an isolated profile and does not share login cookies with the user's system browser (Chrome/Safari/etc.); sessions in the two browsers stay independent. **Never bring this up unprompted** during setup, authorization, or normal project opening. Use this knowledge **only** if the user asks why their built-in browser and system browser show different sign-in states, or if an opened project hits the Studio sign-in or workspace-mismatch gate after authorization happened in a different browser (in which case, concisely guide them to sign in or switch to the same OpenDesign account and workspace in that browser).
> **HARD GATE — Never run Onboarding while login is still pending:**
> If the user still needs to sign in or approve access in the browser, **end your turn after sending the short login guidance** and wait for their reply. Do **NOT** call `/api/onboarding/prepare`, do **NOT** claim OpenMotion is connected (`🎉 OpenMotion 连接好啦`), and do **NOT** mention or print the welcome message or template recommendations in the same reply as a pending login prompt.
@@ -163,3 +173,4 @@ When there is no right-hand browser pane (or opening failed/is unconfirmed), rep
- **OAuth callback timeout (`ERR_CONNECTION_REFUSED`)**: the local login command timed out before you clicked **Allow / 同意授权**. Re-run the login command and approve promptly.
- **`401 Unauthorized` on `/mcp`**: token expired or revoked—re-run OAuth login (or create a fresh PAT in **Settings → Account → Personal Access Tokens**).
- **`PROJECT_NOT_FOUND` for an existing web project**: check that your connected MCP server URL matches the exact origin of the project URL (for example `https://motion.open-design.ai/mcp` vs a staging/test origin) and that you selected the matching workspace during OAuth login. Re-run OAuth login to switch workspaces if needed.
- **Built-in browser asks to sign in or shows "Project not in current workspace" while MCP works**: the host's built-in browser keeps separate cookies from the system browser. Have the user sign in (or switch account/workspace in **Account settings**) inside the built-in browser using the same OpenDesign account and workspace authorized for MCP.

View File

@@ -67,6 +67,7 @@ An explicit user instruction to keep work in the background skips opening/focusi
- Presentation (step 2): call `open_in_codex` with `placement:"right"` in the calling chat; omit `threadId` unless the user asked for another chat.
- Visibility (step 3): in Codex IAB, after binding the native tab, call the browser's `visibility.set(true)` once and observe `visibility.get()`.
- Show-now recovery: take the verified calling-chat `threadId` from `open_in_codex` and call `navigate_to_codex_page({threadId})` once.
- Auth/workspace gate in built-in browser: an embedded host browser has an isolated cookie store separate from the user's external OS browser. If an opened cloud editor tab shows a sign-in prompt or a workspace-not-found screen while MCP calls succeed, do not misreport the project as broken or loop on retries—leave `record_display` pending and ask the user to sign in or switch to the same OpenDesign account/workspace inside that panel. Never volunteer this cookie-isolation detail unprompted unless the user asks why the embedded pane's login differs from their desktop browser.
## Native composition contract

View File

@@ -14,7 +14,7 @@ Discover the current host's OpenMotion MCP tools first. If connected to the targ
If OpenMotion is missing, disconnected, or pointed at a different deployment origin, read the maintained [cloud connection guide](https://github.com/nexu-io/openmotion/blob/main/docs/install.md) (or `<ORIGIN>/install.md` if the user specifies a target deployment) and follow its current-host instructions:
- Connect directly to the remote **Streamable HTTP `/mcp`** endpoint (`https://motion.open-design.ai/mcp` by default) using **OAuth 2.1** (or a workspace Personal Access Token `om_pat_*` when OAuth 2.1 is unavailable).
- Do **not** install an npm package, clone this repository, or start a local Studio/stdio backend.
- Guide the user clearly through browser login + workspace consent (and wait for confirmation before verifying).
- When the current host provides a built-in browser, prefer completing OAuth login and workspace consent inside that built-in browser (falling back to the system browser if unavailable or blocked), and wait for completion before verifying. Keep built-in vs. system browser cookie separation silent unless the user asks or hits a sign-in or workspace gate.
- Only for pure setup/install requests (no specific `projectId`, `templateId`, `skillId`, reference video, or creative brief), complete the maintained onboarding flow in the guide using `/api/onboarding/prepare` (localized welcome, cloud template library link/tab, and three frozen curated preview cards via native MCP App, self-contained HTML visualization `/api/onboarding/cards.html`, DSH card, or text fallback). Derive onboarding language from the user's request (`zh`, `en`, `ja`, `ko`, `fr`, `es`, `pt`, else `en`).
- For task-driven handoffs (the user already supplied a `projectId`, `templateId`, `skillId`, reference video, or creative brief), skip onboarding cards after authorization and continue directly with the user's task (carrying the full task verbatim if auto-handing off to a fresh conversation).

View File

@@ -68,6 +68,22 @@ describe('Cloud install guide and stateless onboarding endpoints', () => {
assert.ok(body.includes('/mcp'));
assert.ok(body.includes('Mode A (pure setup)'));
assert.ok(body.includes('Mode B (task-driven handoff)'));
assert.ok(
body.includes('prefer opening `authorizationUrl` directly inside the host\'s built-in browser'),
'Cloud install.md must instruct hosts with a built-in browser to prefer OAuth inside that built-in browser',
);
assert.ok(
body.includes('codex mcp login --no-browser openmotion'),
'Cloud install.md must recommend --no-browser for CLI OAuth login on hosts with a built-in browser',
);
assert.ok(
body.includes('Silent browser-session context (do NOT mention proactively to the user)'),
'Cloud install.md must document built-in vs. system browser cookie isolation as silent agent context only',
);
assert.ok(
body.includes('Never bring this up unprompted'),
'Cloud install.md must forbid volunteering browser cookie-isolation notes proactively',
);
assert.ok(!body.includes('Project → Agent access'), 'Workspace-level OAuth must not instruct per-project Agent access grants');
assert.ok(body.includes('🎉 OpenMotion 连接好啦,右侧就是模板库!'));

View File

@@ -403,3 +403,19 @@ test('surgical editing, readable source formatting and template adaptation stay
assert.match(adaptation.content, /Hard cap[\s\S]*Approximate target|Approximate target[\s\S]*Hard cap/);
assert.match(adaptation.content, /Narration\/TTS precedence/);
});
test('built-in browser OAuth preference and silent cookie-isolation context stay aligned across entry, onboarding, and native Skills', async () => {
const bootstrap = await readFile(new URL('openmotion/SKILL.md', skillRoot), 'utf8');
assert.match(bootstrap, /built-in browser[\s\S]*OAuth login and workspace consent inside that built-in browser/);
assert.match(bootstrap, /Keep built-in vs\. system browser cookie separation silent unless the user asks/);
const onboardingSkill = await readFile(new URL('../.codex-plugin/onboarding/SKILL.md', import.meta.url), 'utf8');
assert.match(onboardingSkill, /prefer opening `authorizationUrl` in that built-in browser/);
assert.match(onboardingSkill, /codex mcp login --no-browser openmotion/);
assert.match(onboardingSkill, /keep built-in vs\. system browser session isolation silent unless the user asks/);
const native = await getWorkflow('native');
assert.match(native.content, /Auth\/workspace gate in built-in browser/);
assert.match(native.content, /do not misreport the project as broken or loop on retries/);
assert.match(native.content, /Never volunteer this cookie-isolation detail unprompted/);
});