MCP server that gives AI agents geometric spatial awareness of web page layouts using Playwright
About
MCP server that gives AI agents geometric spatial awareness of web page layouts using Playwright
Security Report
This MCP server is well-structured and secure. It uses proper authentication via MCP protocol, validates all inputs with Zod, and avoids dangerous patterns like shell execution or data exfiltration. The server's permissions (network access, browser automation) directly match its stated purpose of analyzing web page layouts. No critical or high-severity vulnerabilities were identified. Supply chain analysis found 1 known vulnerability in dependencies (0 critical, 1 high severity). Package verification found 1 issue.
7 files analyzed Β· 7 issues found
Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.
Permissions Required
This plugin requests these system permissions. Most are normal for its category.
How to Install
Add this to your MCP configuration file:
{
"mcpServers": {
"io-github-vola-trebla-playwright-spatial-layout-mcp": {
"args": [
"-y",
"playwright-spatial-layout-mcp"
],
"command": "npx"
}
}
}Documentation
View on GitHubFrom the project's GitHub README.
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.
π οΈ 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-mcp
Or install globally:
npm install -g playwright-spatial-layout-mcp
npx playwright install chromium
Claude 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
Reviews
No reviews yet
Be the first to review this server!
More Search & Web MCP Servers
Toleno
Freeby Toleno Β· Developer Tools
Toleno Network MCP Server β Manage your Toleno mining account with Claude AI using natural language.
mcp-creator-python
Freeby mcp-marketplace Β· Developer Tools
Create, build, and publish Python MCP servers to PyPI β conversationally.
MarkItDown
Freeby Microsoft Β· Content & Media
Convert files (PDF, Word, Excel, images, audio) to Markdown for LLM consumption
MCP Marketplace
Freeby mcp-marketplace Β· Developer Tools
Search and install MCP servers from inside your AI client.
FinAgent
Freeby mcp-marketplace Β· Finance
Free stock data and market news for any MCP-compatible AI assistant.
Google Workspace MCP
Freeby Taylorwilsdon Β· Productivity
Control Gmail, Calendar, Docs, Sheets, Drive, and more from your AI