Playwright Spatial Layout Mcp

io.github.vola-trebla由 GitHub 帳號 vola-trebla 發布v0.2.0更新於 Oct 24, 2026

MCP server that gives AI agents geometric spatial awareness of web page layouts using Playwright

發布方自己的服務:Layout

已驗證STDIO僅桌面瀏覽器自動化開發者工具

概覽

AI 產生的概覽

以 Playwright 為基礎的 MCP 伺服器,為助理提供真實網頁的邊界框幾何資料,用來分析版面、遮擋與重排。

可以做什麼
  • 量測指定選擇器元素的位置、尺寸、z-index 與視窗可見性
  • 偵測目標元素與浮層之間的視覺遮擋,回傳交集比例與被遮擋面積
  • 驗證 left_of、right_of、above、below、contains、not_overlapping 等版面規則,並回傳通過與否及原因
  • 在多個視窗尺寸下比較元素位置與尺寸,找出版面位移
適用情境
適合排查 Playwright 測試失敗或響應式版面問題:DOM 看似正常,但元素被隱藏、移出畫面、互相重疊或發生位移。也適合檢查橫幅或彈窗是否在特定視窗下擋住主要按鈕。
執行需求
透過 npx 或全域 npm 安裝,以 stdio 在本機執行;需要 Node.js 以及 Playwright 的 Chromium 瀏覽器(npx playwright install chromium)。未宣告帳號、API 金鑰或環境變數。載入被檢查的頁面需要網路存取。
安裝前請注意
這些工具會在本機真實瀏覽器中開啟任意網址,請只指向可信的頁面。結果僅反映指定視窗下的呈現,可能與其他裝置或瀏覽器不同。不涉及任何憑證。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Playwright Spatial Layout Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

playwright-spatial-layout-mcp 🐸📐

[npm version] [npm downloads] [CI] [License: MIT]

An MCP server that gives AI agents geometric spatial awareness of web page layouts using Playwright.

AI agents can read the DOM and know a button exists — but they can't see that it's hidden under a sticky header, pushed off-screen by a broken CSS rule, or overlapping another element on mobile. This MCP fixes that by exposing real bounding box mathematics from a live browser.


🤔 The Problem

When an AI agent analyzes a Playwright test failure, it reads the accessibility tree:

"The Submit button exists in the DOM. It has role=button. It is visible."

What it cannot see:

  • 🙈 The button is at y: 1450px — below the fold on mobile
  • 🙈 A cookie banner overlaps it by 73%, making it unclickable
  • 🙈 On a 375px viewport the nav and hero section overlap each other
  • 🙈 An element shifted 200px to the right after a CSS refactor

playwright-spatial-layout-mcp gives the agent coordinates, intersection ratios, and layout shift data so it can reason about the rendered page — not just the markup.


🛠️ Tools

extract_bounding_boxes

Returns position, size, z-index, and viewport visibility for one or more elements.

json
{  "url": "https://your-app.com",  "selectors": ["header", ".hero-cta", "footer"],  "viewport": { "width": 375, "height": 812 }}
json
[  {    "selector": ".hero-cta",    "box": { "x": 16, "y": 892, "width": 343, "height": 48 },    "z_index": "auto",    "is_visible": true,    "is_in_viewport": false  }]

detect_visual_occlusion

Checks if one element physically overlaps another by computing bounding box intersection.

json
{  "url": "https://your-app.com",  "target_selector": ".checkout-button",  "overlay_selector": ".cookie-banner"}
json
{  "is_occluded": true,  "intersection_ratio": 0.61,  "occluded_area_px": 4128}

verify_spatial_relationships

Validates a set of layout rules and returns pass/fail with a human-readable reason per rule.

Supported rule types: left_of · right_of · above · below · contains · not_overlapping

json
{  "url": "https://your-app.com",  "rules": [    { "type": "above", "element_a": "nav", "element_b": ".hero" },    { "type": "not_overlapping", "element_a": ".sidebar", "element_b": ".main-content" }  ]}
json
{  "passed": false,  "results": [    { "passed": true, "reason": "'nav' bottom (64px) is above '.hero' top (64px)" },    { "passed": false, "reason": "'.sidebar' and '.main-content' overlap by 12%" }  ]}

compute_viewport_reflow

Measures how element positions and sizes change across multiple viewport sizes.

json
{  "url": "https://your-app.com",  "selectors": ["nav", ".hero", ".cta-button"],  "viewports": [    { "width": 375, "height": 812 },    { "width": 768, "height": 1024 },    { "width": 1280, "height": 720 }  ]}
json
[  {    "selector": ".cta-button",    "shifted": true,    "max_delta_x": 442,    "max_delta_y": 318,    "max_delta_width": 897,    "max_delta_height": 0  }]

🚀 Installation

bash
npx playwright-spatial-layout-mcp

Or install globally:

bash
npm install -g playwright-spatial-layout-mcpnpx playwright install chromium

Claude Desktop config

json
{  "mcpServers": {    "playwright-spatial-layout-mcp": {      "command": "npx",      "args": ["-y", "playwright-spatial-layout-mcp"]    }  }}

💡 Example Agent Prompts

"Check if the cookie banner is blocking the checkout button on mobile (375px viewport)"

"Verify that the navigation is above the hero section and the sidebar doesn't overlap the main content"

"Show me which elements shift the most when resizing from desktop to mobile"

"Is the promotional modal covering the primary CTA on iPad viewport?"


🔗 Related Projects


📄 License

MIT © vola-trebla

來源:README.md,提交 6c85ccf

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Layout 整合