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 集成