WebMCP Bridge
Use this skill to operate @webmcp-bridge/local-mcp through one fixed uxc shortcut command per site.
If the target site does not expose native WebMCP and does not already have a fallback adapter, switch to $webmcp-adapter-creator.
Prerequisites
- -
uxc is installed and available in PATH. - INLINECODE5 is installed and available in
PATH. - Network access is available for the target website.
- On a fresh machine, or under an isolated
HOME, install Playwright browsers first with npx playwright install. - For local repo development, you may replace the default
npx -y @webmcp-bridge/local-mcp launcher with WEBMCP_LOCAL_MCP_COMMAND='node packages/local-mcp/dist/cli.js'.
Core Workflow
- 1. Identify the bridge source mode before creating any link:
- Native or polyfill target: use
--url <url>.
- Built-in adapter preset: use
--site <site>.
- Third-party adapter module: use
--adapter-module <specifier> and optionally
--url <url>.
- 2. Pick one stable site name and one site-scoped profile path:
- default profile root:
~/.uxc/webmcp-profile/<site>
- never share one profile across different sites
- 3. Create or refresh the fixed link for that site:
-
command -v <site>-webmcp-cli
- if the link is missing or the source config changed, run
skills/webmcp-bridge/scripts/ensure-links.sh
- 4. Inspect the bridge and tool schema before calling tools:
-
<site>-webmcp-cli -h
-
<site>-webmcp-cli <operation> -h
-
<site>-webmcp-cli <operation> field=value
-
<site>-webmcp-cli <operation> '{"field":"value"}'
- 5. Treat presentation mode as explicit runtime state, not command-name intent:
- check current state with
<site>-webmcp-cli bridge.session.status
- or
<site>-webmcp-cli bridge.session.mode.get
-
--headless or
--no-headless only sets the preferred default for bridge-managed sessions
- the actual runtime mode is
presentationMode
- 6. Switch modes explicitly when needed:
- for normal automation, stay in
headless
- for login, MFA, or human collaboration, run
<site>-webmcp-cli bridge.session.mode.set '{"mode":"headed"}'
- then open or focus the visible session with
<site>-webmcp-cli bridge.open
- if the user manually closes that window, the headed owner session ends; run
bridge.open again to start a new headed session on the same profile
- close the visible owner session with
<site>-webmcp-cli bridge.close
- 7. Parse JSON output only:
- success path:
.ok == true, consume
.data
- failure path:
.ok == false, inspect
.error.code and INLINECODE36
When Only Bridge Tools Are Visible
If <site>-webmcp-cli -h only shows bridge.* tools, do not keep retrying site tools blindly. The bridge is alive, but the page runtime is not attached to site tools yet.
Use this recovery order:
- 1. Inspect session state first:
-
<site>-webmcp-cli bridge.session.status
- 2. If the session is bootstrap-only or auth is incomplete:
- run
<site>-webmcp-cli bridge.session.bootstrap
- complete login in the browser window
- then re-run
<site>-webmcp-cli -h
- 3. If a browser/profile already exists but the session is not attached to page tools:
- run
<site>-webmcp-cli bridge.session.attach
- then re-run
<site>-webmcp-cli -h
- 4. If the task needs a visible browser:
- run
<site>-webmcp-cli bridge.session.mode.set '{"mode":"headed"}'
- run
<site>-webmcp-cli bridge.open
- 5. Only call site operations after help output shows site tools again.
For auth-sensitive adapter sites such as x and google, seeing only bridge tools during first use is expected until bootstrap or attach completes successfully.
Link Contract
Every site gets one fixed command:
The link must keep one stable site profile and daemon lock:
- - profile path: INLINECODE49
- daemon key: same as profile path
The generated command should default to:
- - use INLINECODE50
- use INLINECODE51
This keeps automation deterministic while still allowing runtime switching through:
- - INLINECODE52
- INLINECODE53
- INLINECODE54
- INLINECODE55
Do not treat one command invocation as a guarantee that the current runtime has already switched. Always inspect presentationMode when mode matters.
Guardrails
- - Prefer browser-side execution for privileged site actions. Do not move site credentials into local scripts.
- Do not share one
--user-data-dir across multiple unrelated sites. - Do not dynamically rename link commands at runtime. The skill author chooses the link name once.
- For managed sessions, use
bridge.session.mode.set instead of relying on a new launcher invocation to force a mode change. - For external attach sessions,
bridge.session.mode.set is unavailable. Attach to a headed external browser if the task needs a visible window. - During
bootstrap_then_attach, bootstrap is always headed. Do not try to switch mode until attach completes. - INLINECODE62 and
bridge.window.open return UNSUPPORTED_IN_HEADLESS_SESSION when the current runtime is headless. - For destructive writes, inspect tool help first and require explicit user intent.
- Use
--url only for the site the user asked for. Do not silently redirect hosts.
References
- - Common creation and invocation patterns:
-
references/usage-patterns.md
- - Source mode selection and argument mapping:
-
references/source-modes.md
- - Link patterns, naming, and profile layout:
-
references/link-patterns.md
- - Common failures and recovery steps:
-
references/troubleshooting.md
- - Concrete creation script:
- INLINECODE71
技能名称: webmcp-bridge
详细描述:
WebMCP 桥接
使用此技能,通过每个站点固定的 uxc 快捷命令来操作 @webmcp-bridge/local-mcp。
如果目标站点未暴露原生 WebMCP 且尚未配置回退适配器,请切换到 $webmcp-adapter-creator。
前置条件
- - uxc 已安装并可在 PATH 中使用。
- npx 已安装并可在 PATH 中使用。
- 目标网站可访问网络。
- 在新机器或隔离的 HOME 环境下,首先使用 npx playwright install 安装 Playwright 浏览器。
- 对于本地仓库开发,可以将默认的 npx -y @webmcp-bridge/local-mcp 启动器替换为 WEBMCPLOCALMCP_COMMAND=node packages/local-mcp/dist/cli.js。
核心工作流程
- 1. 在创建任何链接之前,先确定桥接源模式:
- 原生或 polyfill 目标:使用 --url
。
- 内置适配器预设:使用 --site 。
- 第三方适配器模块:使用 --adapter-module ,并可选择使用 --url 。
- 2. 选择一个稳定的站点名称和一个站点范围的配置文件路径:
- 默认配置文件根目录:~/.uxc/webmcp-profile/
- 切勿在不同站点之间共享同一个配置文件
- 3. 为该站点创建或刷新固定链接:
- command -v -webmcp-cli
- 如果链接缺失或源配置已更改,运行 skills/webmcp-bridge/scripts/ensure-links.sh
- 4. 在调用工具之前,检查桥接和工具模式:
- -webmcp-cli -h
- -webmcp-cli -h
- -webmcp-cli field=value
- -webmcp-cli {field:value}
- 5. 将呈现模式视为显式运行时状态,而非命令名称意图:
- 使用 -webmcp-cli bridge.session.status 检查当前状态
- 或使用 -webmcp-cli bridge.session.mode.get
- --headless 或 --no-headless 仅设置桥接管理会话的首选默认值
- 实际运行时模式是 presentationMode
- 6. 在需要时显式切换模式:
- 对于常规自动化,保持在 headless 模式
- 对于登录、多因素认证或人工协作,运行 -webmcp-cli bridge.session.mode.set {mode:headed}
- 然后使用 -webmcp-cli bridge.open 打开或聚焦可见会话
- 如果用户手动关闭该窗口,headed 所有者会话结束;再次运行 bridge.open 以在同一配置文件上启动新的 headed 会话
- 使用 -webmcp-cli bridge.close 关闭可见的所有者会话
- 7. 仅解析 JSON 输出:
- 成功路径:.ok == true,使用 .data
- 失败路径:.ok == false,检查 .error.code 和 .error.message
当仅可见桥接工具时
如果 -webmcp-cli -h 仅显示 bridge.* 工具,不要盲目重试站点工具。桥接处于活动状态,但页面运行时尚未附加到站点工具。
请按以下恢复顺序操作:
- 1. 首先检查会话状态:
- -webmcp-cli bridge.session.status
- 2. 如果会话仅处于引导状态或认证未完成:
- 运行 -webmcp-cli bridge.session.bootstrap
- 在浏览器窗口中完成登录
- 然后重新运行 -webmcp-cli -h
- 3. 如果浏览器/配置文件已存在,但会话未附加到页面工具:
- 运行 -webmcp-cli bridge.session.attach
- 然后重新运行 -webmcp-cli -h
- 4. 如果任务需要可见浏览器:
- 运行 -webmcp-cli bridge.session.mode.set {mode:headed}
- 运行 -webmcp-cli bridge.open
- 5. 仅在帮助输出再次显示站点工具后,才调用站点操作。
对于诸如 x 和 google 等对认证敏感的适配器站点,首次使用时仅看到桥接工具是预期行为,直到引导或附加成功完成。
链接契约
每个站点获得一个固定命令:
该链接必须保持一个稳定的站点配置文件和守护进程锁:
- - 配置文件路径:~/.uxc/webmcp-profile/
- 守护进程键:与配置文件路径相同
生成的命令应默认:
- - 使用 --headless
- 使用 --no-auto-login-fallback
这保证了自动化的确定性,同时仍允许通过以下方式进行运行时切换:
- - bridge.session.mode.get
- bridge.session.mode.set
- bridge.open
- bridge.close
不要将一次命令调用视为当前运行时已切换的保证。当模式重要时,始终检查 presentationMode。
防护措施
- - 对于特权站点操作,优先在浏览器端执行。不要将站点凭据移入本地脚本。
- 不要为多个不相关的站点共享同一个 --user-data-dir。
- 不要在运行时动态重命名链接命令。技能作者应一次性确定链接名称。
- 对于托管会话,使用 bridge.session.mode.set 而不是依赖新的启动器调用来强制更改模式。
- 对于外部附加会话,bridge.session.mode.set 不可用。如果任务需要可见窗口,请附加到 headed 外部浏览器。
- 在 bootstrapthenattach 期间,引导始终是 headed 模式。在附加完成之前,不要尝试切换模式。
- 当当前运行时为 headless 时,bridge.open 和 bridge.window.open 返回 UNSUPPORTEDINHEADLESS_SESSION。
- 对于破坏性写入操作,首先检查工具帮助并要求用户明确意图。
- 仅对用户要求的站点使用 --url。不要静默重定向主机。
参考
- references/usage-patterns.md
- references/source-modes.md
- references/link-patterns.md
- references/troubleshooting.md
- scripts/ensure-links.sh