Playwright Spatial Layout Mcp

io.github.vola-treblaPublished by GitHub account vola-treblav0.2.0Updated Oct 24, 2026

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

The publisher's own server: Layout

VerifiedSTDIODesktop onlyBrowser AutomationDeveloper Tools

Overview

AI-generated overview

Playwright-based MCP server that gives an assistant real bounding-box geometry of live web pages to reason about layout, overlap and reflow.

What you can do
  • Measure element positions, sizes, z-index and viewport visibility for chosen selectors
  • Detect visual occlusion between a target element and an overlay, with intersection ratio and occluded area
  • Verify layout rules such as left_of, right_of, above, below, contains and not_overlapping, with pass/fail reasons
  • Compare element positions and sizes across several viewport sizes to find layout shifts
When to use it
Useful when debugging Playwright test failures or responsive layout bugs where the DOM looks fine but elements are hidden, off-screen, overlapped or shifted. Also handy for checking whether banners or modals block a call to action at specific viewport sizes.
Requirements
Runs locally over stdio via npx or a global npm install; needs Node.js and a Playwright Chromium browser installed (npx playwright install chromium). No accounts, API keys or environment variables are declared. Network access is needed to load the pages being inspected.
Before you install
The tools load arbitrary URLs in a real browser on your machine, so only point them at pages you trust. Results describe the rendered page at the given viewport and may differ from other devices or browsers. No credentials are requested.

Installation

In SourceWeft

  1. Open Playwright Spatial Layout Mcp in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

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

Source: README.md at commit 6c85ccf

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v0.2.0LatestSep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts

Other Layout integrations