Skip to main content
Glama

web-ui-tester

CI

一个 MCP 服务器,让 AI 能够快速驱动和检查真实网页,通过浏览器会话在工具调用之间保持存活。

有两个因素让它很快。页面以带有元素引用的无障碍树的形式暴露,而不是截图或原始 HTML,因此模型可以找到并点击内容,而无需消耗上下文处理标记或等待视觉。而且会话是持久的——cookie、页面状态和历史记录在调用之间保留,因此长时间交互是一系列廉价的步骤,而不是重复的冷启动。

它还携带 DevTools 级别的诊断——控制台、带响应体的网络、JS 求值、计算样式——因此 AI 可以弄清楚为什么出了问题,而不仅仅是知道出了问题。

快速开始

claude mcp add web-ui-tester -- npx -y web-ui-tester

使用内置代理的密钥(参见 run_task):

claude mcp add web-ui-tester \
  -e GOOGLE_GENERATIVE_AI_API_KEY=your-key \
  -- npx -y web-ui-tester

或者在任何 MCP 客户端的配置文件中:

{
  "mcpServers": {
    "web-ui-tester": {
      "command": "npx",
      "args": ["-y", "web-ui-tester"],
      "env": { "GOOGLE_GENERATIVE_AI_API_KEY": "your-key" }
    }
  }
}

Chromium 来自 Playwright。如果尚未安装:

npx playwright install chromium

Related MCP server: Charlotte

会话如何工作

browser_start          → sessionId, kept alive across calls
browser_navigate       → page state + snapshot with [ref=eN] handles
browser_click ref=e12  → act on what the snapshot showed you
browser_snapshot       → fresh refs after the page changes
browser_close          → done (or let it idle out after 30 minutes)

browser_start 之后的所有内容都使用该 sessionId。快照是需要习惯的东西:

- generic [ref=e1]:
  - heading "Signup" [level=1] [ref=e2]
  - textbox "Name" [ref=e5]:
    - /placeholder: Your name
  - combobox "Plan" [ref=e7]
  - button "Create account" [ref=e10]
  - link "Go to second page" [ref=e12] [cursor=pointer]:
    - /url: /second.html

这些引用直接用于 browser_click、browser_type 等。它们属于产生它们的页面状态:导航或 DOM 更改后,请再次快照。当工具说引用不再有效时,请重新快照而不是重试——消息会明确说明。

元素寻址工具也接受 css 或 role + name,当您已经知道选择器并希望跳过快照时。

工具

会话 — browser_start(选项:userAgent、viewportWidth、viewportHeight、headless、baseUrl、url、model)、browser_list、browser_close。

交互 — browser_navigate、browser_click、browser_type、browser_press_key、browser_hover、browser_select_option、browser_scroll、browser_wait_for、browser_go_back、browser_handle_dialog。

操作会报告它们引起的内容:导航、新的控制台错误、请求计数以及出现的任何对话框都会随结果返回,因此悄悄破坏某些内容的点击不会看起来像成功。

对话框需要注意一点。alert/confirm/prompt 会阻塞页面直到得到回答,因此打开它的操作无法同时回答它——未回答的对话框会被自动关闭,而不是使点击停滞,结果会说明这一点。要接受一个对话框,或填写 prompt,请在触发它的操作之前调用 browser_handle_dialog,答案将为下一个对话框做好准备。

检查 — browser_snapshot(可按元素限定范围、depth 限制、interactiveOnly、偏移分页)、browser_query(按角色/名称、文本或 CSS 查找——返回引用和状态)、browser_read_text(页面或一个子树的渲染文本)、browser_screenshot(可用,但树通常是更好的工具)。

诊断 — browser_console(消息以及带堆栈的未捕获错误)、browser_network(状态、大小、时间)、browser_request_detail(标头、时间分解、请求和响应体)、browser_evaluate(在页面中运行 JS)、browser_inspect_element(计算样式、盒模型、表单状态)。

每个结果都限制在字符预算内,大型结果(browser_snapshot、browser_read_text、响应体)使用 offset 分页,而不是静默截断。

内置代理

run_task 将会话交给一个快速模型,该模型自己驱动浏览器并报告:

run_task(sessionId, "Log in as demo@example.com / hunter2 and check the
                     dashboard loads without errors")

报告是关键。 它返回结构化的结论,而不仅仅是散文:

status: success
model: google:gemini-flash-lite-latest

Logged in and opened the dashboard. The revenue widget rendered empty.

findings (3):
  [error] Request failed: GET 500 [observed by the harness]
      where: https://app.example.com/api/revenue
      evidence: HTTP 500
  [error] Console exception on the page [observed by the harness]
      where: app.js:214:9
      evidence: TypeError: Cannot read properties of undefined (reading 'total')
  [warning] The revenue widget shows no empty state, just blank space
      where: #revenue-card
      evidence: card is present but contains no text

发现来自两个地方,区别很重要。代理在运行过程中调用 report_finding——因此达到步骤限制的运行仍然会返回它到目前为止发现的所有内容。另外,测试框架会记录运行期间的所有控制台错误、失败的请求和对话框,并报告这些内容无论代理是否提及,标记为 [由测试框架观察]。错过 500 或忘记提及异常的模型无法隐藏它。

同一报告作为 structuredContent 针对声明的输出模式返回,因此调用 AI 可以根据 findings[].severity 进行分支,而不是解析文本。任务可以成功但仍然有发现;success 反映任务是否完成,而不是页面是否干净。

这是唯一需要 API 密钥的部分。它默认使用 Gemini Flash Lite 以降低延迟;Anthropic 也可以:

默认模型

密钥

Google

gemini-flash-lite-latest

GOOGLE_GENERATIVE_AI_API_KEY

Anthropic

claude-haiku-4-5

ANTHROPIC_API_KEY

设置 WUT_MODEL 来选择(anthropic,或 google:gemini-flash-latest,或任何 provider:modelId)。会话可以通过 browser_start 的 model 覆盖它,单个调用可以通过 run_task 的 model 覆盖。所有其他工具无需密钥即可工作。

HTTP 模式

web-ui-tester --port 7399
claude mcp add --transport http web-ui-tester http://127.0.0.1:7399/mcp

在此模式下,浏览器会话存在于长期运行的服务器中,而不是客户端拥有的进程中,因此它们在客户端重启和重新连接后仍然存活——重新连接,传递相同的 sessionId,页面仍然在那里。GET /health 报告会话和连接数。

它默认绑定到 127.0.0.1,其中启用了 DNS 重新绑定保护。--host 扩大该范围,服务器在您这样做时会发出警告:没有身份验证,任何能访问该端口的人都可以驱动浏览器并通过它运行 JavaScript。请将其放在代理或防火墙后面。

配置

变量

默认值

用途

WUT_MODEL

google:gemini-flash-lite-latest

run_task 的模型,格式为 provider[:modelId]

GOOGLE_GENERATIVE_AI_API_KEY

—

Gemini 的密钥

ANTHROPIC_API_KEY

—

Anthropic 的密钥

WUT_USER_AGENT

AITester/1.0

新会话的默认 User-Agent

WUT_HEADLESS

true

默认无头模式

WUT_IDLE_TIMEOUT_MS

1800000

关闭闲置这么长时间的会话

WUT_MAX_OUTPUT_CHARS

15000

每个工具结果的字符上限

WUT_ACTION_TIMEOUT_MS

5000

单个元素操作的超时

WUT_AGENT_MAX_STEPS

20

run_task 的默认步骤预算

WUT_EXECUTABLE_PATH

—

显式指定 Chromium 二进制文件

PLAYWRIGHT_BROWSERS_PATH

—

Playwright 查找浏览器的位置

CLI 标志:--port、--host、--headless / --no-headless、--idle-timeout、--version、--help。

如果 Playwright 期望的 Chromium 修订版未安装,但安装了另一个,服务器会找到并使用它,而不是失败——在预构建容器中很方便。WUT_EXECUTABLE_PATH 完全覆盖搜索。

开发

npm install
npm run build
npm test          # agent loop (mocked model) + full end-to-end suite
npm run typecheck

npm test 针对脚本化的模拟模型运行代理循环,然后作为真实 MCP 客户端通过两种传输方式驱动构建的服务器,针对本地夹具应用——涵盖引用、过期引用处理、诊断、跨重连的会话持久性以及空闲回收。npm run test:agent:live 额外针对真实提供商运行 run_task,并在未设置密钥时跳过自身。

CI 在每次推送和拉取请求时在 Node 20 和 22 上运行类型检查、构建和两个套件。实时代理测试单独运行——按需通过 Live agent test 工作流,以及每周——因为它进行真实的 API 调用;它需要 GOOGLE_GENERATIVE_AI_API_KEY 或 ANTHROPIC_API_KEY 作为仓库机密,并且当两者都未设置时,计划运行会跳过自身。

许可证

MIT

Available Tools

26 tools
browser_call_toolCall a page or DevTools toolA

Runs a tool from browser_list_tools against the session's page, with arguments matching its browser_tool_schema. WebMCP tools are code the site supplies: their output is the site's word, and one marked CONSEQUENTIAL can take real actions (orders, payments, messages).

Inputs: name (required), sessionId (required), arguments, timeoutMs.

browser_clickClickA

Clicks an element. Address the element by ref (from the latest browser_snapshot), or by css, or by role+name. Reports any navigation, console errors, or network activity the click triggered.

Inputs: sessionId (required), css, ref, name, +5 more.

browser_closeClose sessionA

Closes a browser session and frees its resources.

Inputs: sessionId (required).

browser_consoleConsole logA

Returns buffered console messages and uncaught page errors (with stacks). Check this whenever the page misbehaves — it usually names the failure directly.

Inputs: sessionId (required), clear, level, limit, +1 more.

browser_evaluateEvaluate JavaScriptA

Runs JavaScript in the page and returns the JSON-serialized result. Accepts a bare expression ("document.title") or a function ("el => el.value"). When an element is targeted, it is bound to el. Use it to read state the accessibility tree does not expose.

Inputs: sessionId (required), expression (required), css, ref, +4 more.

browser_go_backGo backB

Navigates back in history and returns the new page state with fresh refs.

Inputs: sessionId (required).

browser_handle_dialogHandle dialogA

Answers an alert/confirm/prompt. A dialog blocks the page until it is answered, so an unanswered one is dismissed automatically rather than stalling the action that opened it. Call this BEFORE the action that triggers a dialog to arm the answer — that is the only way to accept one or supply prompt() text. Called while a dialog is open, it answers that dialog immediately.

Inputs: accept (required), sessionId (required), promptText.

browser_hoverHoverA

Hovers an element, e.g. to reveal a menu or tooltip. Address the element by ref (from the latest browser_snapshot), or by css, or by role+name.

Inputs: sessionId (required), css, ref, name, +2 more.

browser_inspect_elementInspect elementA
Read-only

DevTools-style inspection of one element: tag, attributes, box model, form state, and computed styles. Use it to diagnose layout and visibility problems.

Inputs: sessionId (required), css, ref, name, +3 more.

browser_listList sessionsA
Read-only

Lists open browser sessions with their current URL, age, and idle time.

Inputs: no named parameters.

browser_list_toolsList page and DevTools toolsA
Read-only

Lists tools beyond this server's own that can run against the session's page, by qualified name: "webmcp." for tools the site itself publishes through WebMCP (read live — they change as the page navigates), and "devtools." for chrome-devtools-mcp's tools (performance traces, Lighthouse, emulation, heap snapshots…), which this server runs for you — no extra MCP server to configure. Follow with browser_tool_schema, then browser_call_tool.

Inputs: sessionId (required), source.

browser_navigateNavigateA

Navigates the session to a URL and returns the new page state plus a fresh snapshot with element refs. Relative URLs resolve against the session baseUrl.

Inputs: url (required), sessionId (required), waitUntil.

browser_networkNetwork logA
Read-only

Lists network requests the session has made, with status, size, and duration. Each line carries an #id for browser_request_detail. WebSockets appear as WS entries with their frame counts. Filter by URL substring or by failure status.

Inputs: sessionId (required), limit, filter, status.

browser_press_keyPress keyB

Presses a key, optionally focused on an element. Key names follow Playwright ("Enter", "Escape", "ArrowDown", "Control+a").

Inputs: key (required), sessionId (required), css, ref, +3 more.

browser_queryQuery elementsA
Read-only

Finds elements by role+name, visible text, or CSS, and returns a compact line per match including its ref and visible/enabled state. Use this instead of a full snapshot when you already know what you are looking for.

Inputs: sessionId (required), css, name, role, +2 more.

browser_read_textRead textA
Read-only

Returns the rendered text of the page or of one element subtree — the readable content without markup. Use it to verify copy, read results, or check an error message.

Inputs: sessionId (required), css, ref, name, +4 more.

browser_request_detailRequest detailA
Read-only

Inspects one request from browser_network: headers, timing breakdown, request body, or response body. Small text responses are cached, so they stay readable after navigation. For a WebSocket entry, any part returns its frame stream.

Inputs: id (required), sessionId (required), part, offset, +1 more.

browser_screenshotScreenshotA
Read-only

Captures a JPEG of the page or an element. Use this only for genuinely visual questions (layout, styling, rendering); browser_snapshot and browser_read_text are faster and cheaper for finding and verifying content.

Inputs: sessionId (required), css, ref, name, +3 more.

browser_scrollScrollA

Scrolls an element into view, or scrolls the page by a pixel delta when no element is given.

Inputs: sessionId (required), dx, dy, css, +4 more.

browser_select_optionSelect optionA

Selects one or more options in a . Address the element by ref (from the latest browser_snapshot), or by css, or by role+name.

Inputs: values (required), sessionId (required), css, ref, +3 more.

browser_snapshotSnapshot pageA
Read-only

Returns the accessibility tree of the page as compact YAML, with a [ref=eN] handle on every element. This is the primary way to see the page — use these refs to click and type. Far cheaper than HTML or screenshots. Scope it with ref/css/role, cap it with depth, or page through it with offset when a page is large.

Inputs: sessionId (required), css, ref, name, +7 more.

browser_startStart browser sessionA

Opens a new browser session and returns its sessionId. The session (cookies, storage, page state) stays alive across tool calls until closed or idle-timed-out, so you can interact with the same page over many turns.

Inputs: tab, url, model, cdpUrl, +7 more.

browser_tool_schemaGet a tool's schemaA
Read-only

Full description and JSON input schema of a tool from browser_list_tools, e.g. "webmcp.search" or "devtools.performance_start_trace".

Inputs: name (required), sessionId (required).

browser_typeType textA

Types text into an input or textarea. Address the element by ref (from the latest browser_snapshot), or by css, or by role+name.

Inputs: text (required), sessionId (required), css, ref, +5 more.

browser_wait_forWait for conditionA

Waits for text to appear, text to disappear, or a selector to become visible. Use after actions that trigger async updates.

Inputs: sessionId (required), text, selector, textGone, +1 more.

run_taskRun UI taskA

Delegates a multi-step UI task to a fast built-in browser agent, which drives the session itself and reports back. Use it for goal-shaped work ("log in as demo@example.com and check the dashboard loads", "walk the checkout flow and report anything broken") rather than driving each click yourself.

Returns a structured report: a success flag, a summary, and findings — each with a severity, what is wrong, where, and the evidence observed. Findings come from two places: what the agent noticed, and what the harness itself recorded (console errors, failed requests, dialogs), so problems are reported even when the agent does not mention them or runs out of steps. The session is left on whatever page the agent ended on, so you can inspect it further with the browser_* tools.

Inputs: sessionId (required), instruction (required), model, maxSteps, +1 more. Returns: model, steps, success, summary, +6 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 26 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: interaction (click/type/hover/press_key/select_option), navigation, and session management are unambiguous. The main soft overlap is among the page-reading tools (browser_snapshot, browser_query, browser_read_text, browser_inspect_element, browser_screenshot), but the descriptions explicitly explain when to prefer each, so misselection risk is low.

    Naming Consistency4/5

    Nearly all tools use a browser_ prefix with snake_case, which is highly predictable. Slight deviation: some are verb-first (browser_navigate, browser_click) while others are noun-first (browser_console, browser_network, browser_snapshot), and run_task drops the prefix, but the style is coherent overall.

    Tool Count3/5

    At 26 tools the surface is on the heavy side, but browser automation is a genuinely broad domain spanning sessions, interaction, inspection, network, dialogs, and delegation. Few tools feel redundant, though the count is borderline rather than tightly scoped.

    Completeness5/5

    The surface covers the full automation lifecycle: session start/list/close, navigation and history, element interaction, form filling, dialog handling, waiting, accessibility/text/visual inspection, JS evaluation, console and network diagnostics, plus a meta-tool layer and a delegated run_task agent. No obvious dead ends for typical UI testing.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables AI agents to browse and interact with web pages through a persistent headless Chromium session, serving compact structured orientations, targeted element queries, and full detail only when explicitly requested. It supports navigation, observation, form filling, monitoring, and session management while cutting token overhead by up to ~140x versus raw accessibility-tree dumps.
      4 npm
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to browse and interact with websites through a persistent headless Chromium session, returning compact structured page representations instead of full accessibility-tree dumps. Agents can navigate, query specific elements and forms, click, type, manage tabs and cookies, and monitor console or network activity while paying a fraction of the tokens.
      4 npm
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to browse and interact with web pages through a token-efficient, structured page representation — orientation summaries, targeted element queries, and full detail only on request — instead of raw accessibility-tree dumps. Supports navigation, interaction, forms, screenshots, console and network monitoring, session/tab management, and browser-based development auditing.
      4 npm
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to browse and interact with web pages through a persistent headless Chromium session, returning compact structured page summaries, targeted element queries, and full detail only on request. This keeps token usage far below full accessibility-tree snapshots while still supporting navigation, forms, screenshots, and session control.
      4 npm
      -