playwright-spatial-layout-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@playwright-spatial-layout-mcp Check if the cookie banner is blocking the checkout button on mobile (375px viewport)"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
playwright-spatial-layout-mcp πΈπ
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.
Related MCP server: visual-ui-debug-agent-mcp
π οΈ Tools
extract_bounding_boxes
Returns position, size, z-index, and viewport visibility for one or more elements.
{
"url": "https://your-app.com",
"selectors": ["header", ".hero-cta", "footer"],
"viewport": { "width": 375, "height": 812 }
}[
{
"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.
{
"url": "https://your-app.com",
"target_selector": ".checkout-button",
"overlay_selector": ".cookie-banner"
}{
"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
{
"url": "https://your-app.com",
"rules": [
{ "type": "above", "element_a": "nav", "element_b": ".hero" },
{ "type": "not_overlapping", "element_a": ".sidebar", "element_b": ".main-content" }
]
}{
"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.
{
"url": "https://your-app.com",
"selectors": ["nav", ".hero", ".cta-button"],
"viewports": [
{ "width": 375, "height": 812 },
{ "width": 768, "height": 1024 },
{ "width": 1280, "height": 720 }
]
}[
{
"selector": ".cta-button",
"shifted": true,
"max_delta_x": 442,
"max_delta_y": 318,
"max_delta_width": 897,
"max_delta_height": 0
}
]π Installation
npx playwright-spatial-layout-mcpOr install globally:
npm install -g playwright-spatial-layout-mcp
npx playwright install chromiumClaude Desktop config
{
"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
playwright-trace-decoder-mcp β root-cause analysis of CI failures from Playwright traces
flakiness-knowledge-graph-mcp β knowledge graph of flaky test patterns
ast-impact-mapper-mcp β find affected tests from code changes via TypeScript AST
zod-contract-mock-forge-mcp β deterministic mock generation from Zod schemas
π License
MIT Β© vola-trebla
Available Tools
6 toolscalculate_perceptual_contrastA
Measures color contrast between a text element and its background using both WCAG 2.x and APCA (WCAG 3.0 draft) formulas simultaneously. Use to answer: does this text pass accessibility contrast requirements? Is it actually readable even if it technically passes the legacy formula?
Inputs: url (required), text_selector (required), background_selector (required), viewport.
compute_viewport_reflowA
Measures how element positions and sizes change across multiple viewport sizes. Use to answer: does the layout break on mobile? Which elements shift most when resizing?
Inputs: url (required), selectors (required), viewports (required).
detect_visual_occlusionA
Checks if one element physically overlaps another by computing the intersection of their bounding boxes. Use to answer: is this button hidden under a sticky header? Does the cookie banner block the CTA?
Inputs: url (required), target_selector (required), overlay_selector (required), viewport.
extract_bounding_boxesA
Returns the geometric position, size, z-index, and viewport visibility for one or more DOM elements. Use to answer: where exactly on screen is this element? Is it visible? Is it off-screen?
Inputs: url (required), selectors (required), viewport.
verify_spatial_relationshipsA
Validates a set of spatial layout rules β e.g. 'nav must be above hero', 'sidebar must be left of content'. Returns pass/fail per rule with a human-readable reason. Use to answer: does the page layout match the design specification?
Inputs: url (required), rules (required), viewport.
verify_stacking_contextA
Reveals the full CSS stacking context chain for an element β which ancestors create new stacking contexts and why. Use to answer: why is my z-index:9999 element still behind a modal? Does this element create its own stacking context?
Inputs: url (required), selector (required), viewport.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 6 tools
Each tool targets a distinct spatial layout concern: geometric extraction, occlusion, rule validation, responsive reflow, contrast, and stacking context. There is no meaningful overlap between their purposes.
All tool names follow the same verb_noun pattern in snake_case (extract_bounding_boxes, detect_visual_occlusion, verify_spatial_relationships, compute_viewport_reflow, calculate_perceptual_contrast, verify_stacking_context). The two 'verify' tools differ clearly in their object.
Six tools is well-scoped for a spatial layout analysis server. Each tool addresses a clear aspect of layout inspection without redundancy or bloat.
The tool surface covers the core spatial layout domain: geometry, overlap, relationship rules, responsive behavior, color contrast, and stacking contexts. No significant gaps are apparent for the stated purpose.
Maintenance
Related MCP Connectors
Web search API and MCP server for developers building AI agents.
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Turn any public website into an MCP server for agents to search, read and navigate.
Screenshot, diff, audit and sitemap-capture any web page β 5 MCP tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that gives AI agents real browser capabilities including screenshotting, action execution, data extraction, and multi-persona auditing for frontend validation.63 npm6MIT
- AlicenseCqualityCmaintenanceAn MCP server that enables AI agents to autonomously test, debug, and analyze web interfaces visually using Playwright, with 30 tools for screenshots, workflows, performance, and visual comparison.3014 npm84ISC
- AlicenseNot gradedqualityNot gradedmaintenanceAn MCP server that enables AI agents to automate browser interactions using Playwright and Cloudflare Workers, supporting tasks like navigation, clicking, typing, and screenshots.9,076 npmApache 2.0
- AlicenseAqualityCmaintenanceAn MCP server that enables AI assistants to visually inspect and interact with rendered web pages via a persistent headless Chromium browser, supporting navigation, screenshots, clicks, viewport resizing, and console log retrieval.81MIT