pxtree

io.github.alabsi91由 GitHub 账号 alabsi91 发布v0.1.2更新于 Oct 24, 2026

Measures how a webpage actually renders and prints it as compact text for AI coding agents.

已验证STDIO仅桌面浏览器自动化开发者工具

概览

AI 生成的概览

在无头 Chromium 中加载网页,把实际渲染结果输出为紧凑文本树和测量数据,让助手无需截图即可检查页面布局。

可以做什么
  • 以紧凑文本树测量页面渲染后的盒子、尺寸、内边距、间距和文字度量
  • 列出基于阈值的发现,例如同级元素顶部不齐、宽高不一致、间距不均
  • 与同一网址或同一 diff key 的上一次运行对比,查看变化
  • 在同一次调用中附加无障碍(aria)快照,并可保存 PNG 截图
  • 把输出缩减为仅发现、摘要、仅变化或仅事实行
  • 读取内置指南,了解输出语法、标签和限制
适用场景
适合助手修改前端代码后,需要确认页面在多种视口尺寸和配色方案下实际如何渲染,或验证某次布局修复是否改变了数值。适用于布局与间距调试,此时以 CSS 像素为单位的数值比截图更有用。
运行要求
通过 npx 以 stdio 在本地运行,需要 Node 20 或更高版本。需先安装一次 Playwright 的 Chromium(约 150 MB),也可改用已安装的 Chrome。未声明账号、API 密钥或环境变量。目标页面需可访问,可以是本地开发服务器、服务器工作目录下的文件或网址。
安装前请注意
script 输入是受信任的代码,会以 Node 形式在服务器进程内执行,只应对可信内容使用。文件目标限制在工作目录内,说明中称其用于防止误操作,而非安全边界。截图写入临时目录,运行历史保存在项目之外的缓存目录。页面在真实浏览器中加载,因此远程网址会从本机发起请求。

安装

在 SourceWeft 中

  1. 打开 控制台中的 pxtree,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

pxtree

Loads a webpage in headless Chromium and prints what actually rendered as a compact text tree, so an AI coding agent can check a layout without a screenshot.

A dev server page with a row of three cards, a row of three plans, a list of steps, a row of stats, an article, a form, a column of prices and a row of tiles:

$ npx -y pxtree@latest localhost:51731280x800 light dpr 1 ltr scroll 0/382 page 1280x1182 painted to 1134since last run: no changessummary: 7 findings  a.button tops 64..136 across siblings: ul.cards  div.stat tops 0..6 across siblings: div.stats  input.field starts 0..3 across siblings: form.fields  12 wider than li.plan: li.plan.featured  72 taller than li.card: li.card 3 of 3  20 shorter than div.tile: div.tile.short  gaps 16 16 24 16 between li.step: ul.stepsbody 1280x1182 [pad 24][gaps 24 24 24 24 16 16 …, free 24 at end]  ul.cards 1232x208 [gaps across 16, free 600 at end][!! a.button tops 64..136 across siblings]    li.card 200x136 [pad 16][gaps 8][renders background]      h3 "Starter" 168x24 [text 19/24]      p "Short text." 168x24 @0,32 [text 16/24]      a.button "Choose" 168x40 @0,64 [pad 8 16][text 16/24][renders background]    li.card 200x136 @216,0 [pad 16][gaps 8][renders background]      h3 "Team" 168x24 [text 19/24]      p "Short text." 168x24 @0,32 [text 16/24]      a.button "Choose" 168x40 @0,64 [pad 8 16][text 16/24][renders background]    li.card 200x208 @432,0 [pad 16][gaps 8][renders background][!! 72 taller than li.card]      h3 "Business" 168x24 [text 19/24]      p "A much longer…" 168x96 @0,32 [text 16/24, 4 lines, 444 on one line]      a.button "Choose" 168x40 @0,136 [pad 8 16][text 16/24][renders background]  ul.plans 1232x56 @0,232 [gaps across 16, free 588 at end]    li.plan "Monthly" 200x56 [pad 16][text 16/24][renders background]    li.plan "Yearly" 200x56 @216,0 [pad 16][text 16/24][renders background]    li.plan.featured "Lifetime" 212x56 @432,0 [pad 16][text 16/24][renders background][!! 12 wider than li.plan]  ul.steps 1232x192 @0,312 [gaps 16 16 24 16][!! gaps 16 16 24 16 between li.step]    li.step "One" 1232x24 [text 16/24]    li.step "Two" 1232x24 @0,40 [text 16/24]    li.step.active "Three" 1232x24 @0,80 [text 16/24]    li.step "Four" 1232x24 @0,128 [text 16/24]    li.step "Five" 1232x24 @0,168 [text 16/24]  div.stats 1232x62 @0,528 [gaps across 16, free 456 at end][!! div.stat tops 0..6 across siblings]    div.stat "Revenue" 182x56 [pad 16][text 16/24][renders background]    div.stat "Orders" 182x56 @198,0 [pad 16][text 16/24][renders background]    div.stat.alert "Refunds" 182x56 @396,6 [pad 16][text 16/24][renders background]    div.stat "Customers" 182x56 @594,0 [pad 16][text 16/24][renders background]  article 1232x132 @0,614 [gaps 12]    h2 "First heading" 1232x24 [text 24/24]    p "First paragraph." 1232x24 @0,36 [text 16/24]    h2 "Second heading" 1232x24 @0,72 [text 24/24]    p "Second paragraph." 1232x24 @0,108 [text 16/24]  p.with-link "Read the first." 1232x24 @0,762 [text 16/24]    a "guide" 39x17 @69,3 [text 16/24]  form.fields 1232x108 @0,802 [gaps 8][!! input.field starts 0..3 across siblings]    input.field "Name" 208x21 [pad 1 2][text 13/15][renders background, border]    input.field "Email" 208x21 @0,29 [pad 1 2][text 13/15][renders background, border]    input.field.nudged "Company" 208x21 @3,58 [pad 1 2][text 13/15][renders background, border]    input.field "Phone" 208x21 @0,87 [pad 1 2][text 13/15][renders background, border]  div.prices 300x72 @0,934    span.price "$9" 18x24 @282,0 [text 16/24]    …×2 similar span.price 36x24..49x24  div.tiles 1232x80 @0,1030 [gaps across 16, free 900 at end]    div.tile 100x80 [renders background]    div.tile.short 100x60 @116,0 [renders background][!! 20 shorter than div.tile]    div.tile 100x80 @232,0 [renders background]

The first line is the facts line: viewport, color scheme, device pixel ratio, direction, scroll position out of the maximum, document size, and painted to, the lowest painted pixel. since last run compares with the previous run of the same URL and settings, or of the same --diff-key name. That history lives in ~/.cache/pxtree, never in your project, and --no-diff skips it.

The ul.cards line says the "Choose" buttons in the three cards have tops from 64 px to 136 px below the top of their card. The li.plan.featured "Lifetime" line says that plan is 212x56 at x 432 in its row, 12 px wider than the width its siblings share. Findings are measurements with a threshold, never verdicts. The agent decides from the code whether they are intended.

Why not a screenshot

  • It gives numbers in CSS px, not pixels the model has to estimate.
  • The agent reads it in one pass, as text, with the findings listed on top.
  • One call covers several viewports and color schemes.

Install

pxtree drives Playwright's Chromium. Install it once, about 150 MB:

npx -y [email protected] install chromium

pxtree itself downloads nothing and never edits your project. --channel chrome uses an installed Chrome instead. Needs Node 20 or newer.

MCP server

ClientInstallScope
Codexcodex mcp add pxtree -- npx -y pxtree@latest mcpuser, ~/.codex/config.toml
Claude Codeclaude mcp add --scope user pxtree -- npx -y pxtree@latest mcpuser. --scope project writes .mcp.json
Cursor[Install in Cursor] or ~/.cursor/mcp.json / .cursor/mcp.jsonuser / project
VS Code Copilot[Install in VS Code] or code --add-mcp '{"name":"pxtree","command":"npx","args":["-y","pxtree@latest","mcp"]}'user. .vscode/mcp.json for project, see below
OpenCode~/.config/opencode/opencode.json or opencode.json, see belowuser / project

OpenCode, opencode.json:

json
{  "$schema": "https://opencode.ai/config.json",  "mcp": {    "pxtree": { "type": "local", "command": ["npx", "-y", "pxtree@latest", "mcp"], "enabled": true }  }}
Other clients and config files

Any MCP client that reads mcpServers:

json
{  "mcpServers": {    "pxtree": { "command": "npx", "args": ["-y", "pxtree@latest", "mcp"] }  }}
ClientCommand or config pathScope
Claude Code plugin (MCP server and skill)/plugin marketplace add alabsi91/pxtree, then /plugin install pxtree@pxtreeuser
Gemini CLIgemini mcp add -s user pxtree npx -y pxtree@latest mcpuser. Without -s user: project .gemini/settings.json
Devin (formerly Windsurf)devin mcp add pxtree -- npx -y pxtree@latest mcp, files ~/.config/devin/mcp_config.json / .devin/mcp_config.jsonuser / project
Ampamp mcp add pxtree -- npx -y pxtree@latest mcp, files ~/.config/amp/settings.json / .amp/settings.json, see belowuser / project
Zed~/.config/zed/settings.json, see belowuser
ClineCLI: cline mcp or ~/.cline/mcp.json. VS Code extension: Cline panel, MCP Servers, Configureuser
Roo Code.roo/mcp.json, or mcp_settings.json from Roo's settingsproject / user
JetBrains AI AssistantSettings, Tools, AI Assistant, Model Context Protocol (MCP): paste the JSON above. The file path is not documented, check your client's docsuser / project

VS Code, .vscode/mcp.json:

json
{  "servers": {    "pxtree": { "type": "stdio", "command": "npx", "args": ["-y", "pxtree@latest", "mcp"] }  }}

Amp, settings.json:

json
{  "amp.mcpServers": {    "pxtree": { "command": "npx", "args": ["-y", "pxtree@latest", "mcp"] }  }}

Zed, settings.json:

json
{  "context_servers": {    "pxtree": { "command": "npx", "args": ["-y", "pxtree@latest", "mcp"], "env": {} }  }}

MCP Registry name: io.github.alabsi91/pxtree. The server has two tools: measure, and read_me_first, which returns what the skill holds: how to use pxtree, how to report, and the reading guide. Its instructions tell the agent to call read_me_first once per session, so no skill install is needed.

measure takes target and the CLI flags as inputs: viewports, schemes, scroll, element, children, colors, wait, script, screenshot (true saves a PNG per run under the temp directory), timeout, maxChars (default 80000), diff, diffKey, report (tree, findings, summary, changes or none) and aria (true adds the aria tree). One call can return the report, the aria tree and a screenshot together. Inputs are bounded: viewport sides 1 to 10000, at most 10 viewports, timeout at most 120000. A file target must sit under the server's working directory. That rule prevents accidents and is not a security boundary: script is trusted code that runs as Node in the server process.

Skill

For agents that read Agent Skills, Codex included through .agents/skills:

npx -y skills add alabsi91/pxtree

Or link it by hand. ~/.agents/skills is read by Codex, Cursor, Copilot, Gemini CLI, OpenCode, Amp and Devin. Claude Code reads ~/.claude/skills.

git clone https://github.com/alabsi91/pxtreemkdir -p ~/.agents/skills ~/.claude/skillsln -s "$PWD/pxtree/skills/pxtree" ~/.agents/skills/pxtreeln -s "$PWD/pxtree/skills/pxtree" ~/.claude/skills/pxtree

Use <project>/.agents/skills or <project>/.claude/skills for one project only.

Shell-only agents

Tell the agent to run this. It prints the flags, the output grammar, every tag and finding, and the limits.

npx -y pxtree@latest guide

CLI

npx -y pxtree@latest https://example.com --viewport 390x844,1280x800 --scheme light,darknpx -y pxtree@latest localhost:5173 --scroll '#pricing' --element '.card'npx -y pxtree@latest ./dist/index.htmlnpx -y pxtree@latest localhost:5173 --script "await page.click('text=Menu')" --wait '.menu'npx -y pxtree@latest localhost:5173 --element '#pricing' --screenshot pricing.pngnpx -y pxtree@latest localhost:5173 --viewport 390,1280npx -y pxtree@latest localhost:5173 --report summary --arianpx -y pxtree@latest localhost:5173 --report findingsnpx -y pxtree@latest localhost:5173 --report changesnpx -y pxtree@latest localhost:5173 --report none --screenshot shot.png

The screenshot is clipped to the --element match only when the selector matches exactly one element. Otherwise it is the whole viewport, and the facts line says how many matched.

--report picks how much of the measurement prints: tree (the default, everything), findings (the tree cut down to the lines with a finding and the names of their ancestors), summary (no tree), changes (the facts line and since last run, to check a fix) or none (the facts line only). A width alone in --viewport gets a matching height: 390x844, 768x1024, 820x1180, 1024x768, 1280x800, 1440x900, 1920x1080, and 800 for any other width. --aria adds Playwright's aria snapshot of the page, or of each --element match, after the report: roles, names, states and reading order, taken in the same state as the measurement. So one call can carry the findings, the accessibility tree and a screenshot.

npx -y pxtree@latest --help lists the flags. npx -y pxtree@latest guide explains how to read the output.

Limits

  • Coverage is checked only inside the viewport.
  • Declarative closed shadow roots are not walked.
  • iframes are not walked. Measure the frame URL on its own.
  • Pseudo-element ink is placed on the element's box.
  • Clip paths count as their border box. Border radius is ignored.
  • Inside a rotated or scaled box there are no overlap, centering or width findings. Its axis-aligned boxes do not say where things are.
  • Contrast is not measured over images or gradients, where the [text] tag says on image, nor for a transparent text fill such as gradient text, where it says fill transparent.
  • small target skips links inside a line of text and targets with enough spacing, as WCAG 2.5.8 allows.
  • pxtree does not guess intent. A full-bleed section, an avatar stack, an open popover or a collapsed panel prints its numbers like anything else.
  • Desktop emulation only: (hover: hover) and (pointer: fine) match. No touch.
  • Vertical writing modes print physical positions.
  • Loading waits at most 2 s for load and 1.5 s for a quiet network, which files skip. Slower pages need --wait.

API

ts
import { createSession, format } from 'pxtree';
const session = await createSession();const result = await session.measure('localhost:5173', { viewports: [{ width: 390, height: 844 }] });console.log(format(result));await session.close();

License

MIT

来源:README.md,提交 7ea7617

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

2
  1. v0.1.2最新Sep 24, 2026
  2. v0.1.0Sep 24, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分