pagesnap-mcp
pagesnap-mcp
一个 MCP 服务器,用来包装现有的 PageSnap 会话包,让 LLM 能够列出会话、读取定位器,并把它们映射到 Playwright、Selenium 或 Cypress。
这不是一个采集工具。它不会打开浏览器、自动扫描 URL 或抓取浏览器。Playwright 不是依赖项。
采集发生在 pagesnap-playwright 或 pagesnap-selenium 中。请把这个服务器指向一个会话包的父文件夹(flow\.md 加上 yaml,以及可选的 PROMPT.md)。
如何运行
npm install
npm run build
node dist/index.js进程通过 stdio 与 MCP 通信,并等待 stdin。它在终端里看起来像卡住了;这是正常现象。用 Ctrl+C 停止。
可选环境变量:PAGESNAP\_SESSIONS\_DIR(默认 ./sessions)是 PageSnap 会话文件夹的父目录。
Related MCP server: semantic-dom-mcp
Cursor MCP 配置
示例 .cursor/mcp.json。把 PAGESNAP\_SESSIONS\_DIR 指向一个 PageSnap 会话父目录,例如 playwright-ts-framework/snapshots:
{
"mcpServers": {
"pagesnap": {
"command": "node",
"args": [
"/absolute/path/to/pagesnap-mcp/dist/index.js"
],
"env": {
"PAGESNAP_SESSIONS_DIR": "/absolute/path/to/playwright-ts-framework/snapshots"
}
}
}
}这个服务器只读取磁盘上已有的包。它不是一个采集工具。
工具
省 token:list\_sessions 和 read\_session 先返回键和摘要。不会一次性输出 YAML 文件正文。
list\_sessions:无参数。从PAGESNAP\_SESSIONS\_DIR获取会话。read\_session:{ session }。flow\.md、yaml文件名、解析后的控件(上限 200)。map\_locator:{ by, value, name?, framework? }。片段、得分、稳定性。framework:playwright|selenium|cypress(默认playwright)。get\_prompt:{ session, framework? }。如果存在PROMPT.md就返回它;否则返回一个合成的 prompt。
定位
YAML by 值:testid、role、label、id、name、placeholder、linkText、css、xpath。
得分与 PageSnap 一致:testid 98、role 95、label/id 90、name 88、placeholder 85、linkText 75、css 60、xpath 40。
Playwright testid 总是映射到 page.getByTestId(...)。Sauce Demo 使用data-testid,同时使用 Playwright 的 testIdAttribute;仍然输出 getByTestId。通用且没有 role 的 data-testid 节点仍然映射到 getByTestId,绝不会映射到 getByRole('generic')。
测试
npx vitest run许可证
MIT
Available Tools
4 toolsget_promptA
Return PROMPT.md for a session if present; otherwise synthesize a test-generation prompt from flow.md and ranked locators.
Inputs: session (required), framework.
list_sessionsA
List PageSnap session packs under PAGESNAP_SESSIONS_DIR (default ./sessions). Returns a summary only: name, path, mtime, goal, stepCount. Does not capture or open a browser.
Inputs: no named parameters.
map_locatorA
Map a PageSnap YAML locator {by, value} to a Playwright, Selenium, or Cypress snippet with score and stability. Sauce Demo data-test ids still emit getByTestId (configure testIdAttribute in Playwright). Never maps testid to getByRole('generic').
Inputs: by (required), value (required), name, framework.
read_sessionA
Read one PageSnap session: flow.md, YAML file names, and parsed controls (cap 200). Token-efficient: keys/summary first; does not dump YAML file bodies.
Inputs: session (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool maps to a clearly distinct concern: listing sessions, reading session details, translating locators, and generating prompts. There is no overlap that would cause an agent to select the wrong tool.
All tool names follow a consistent verb_noun snake_case pattern: list_sessions, read_session, map_locator, get_prompt. This makes the tool set predictable and easy to navigate.
Four tools is a tight, focused scope. Each tool earns its place and supports a distinct step in the PageSnap session inspection workflow without redundancy.
The read-and-analyze workflow is well covered: list, read, map, and prompt. A minor gap is the lack of session creation or mutation tools, but the descriptions frame this as a read-only inspection tool, so the gaps are acceptable.
Maintenance
Related MCP Connectors
Give agents eyes on any web page: structured context, and changes explained in plain language.
Undetectable cloud browser sessions for AI agents and scrapers. Navigate, extract, click, captcha.
Give AI agents a real cloud Chrome: open sessions, navigate, read pages, click, type and screenshot.
Captured web interfaces, screenshots, flows and structured evidence for AI coding agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to understand web page structure and content through structured data extraction and element discovery using Playwright, eliminating the need for screenshots.49 npmMIT
- AlicenseAqualityBmaintenanceDrives a real Chromium browser to extract a page's DOM into compact Semantic JSON with Playwright-native locators, enabling AI agents to generate consistent, accurate Playwright tests.1325 npm3MIT
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to interact with web pages through structured accessibility snapshots using Playwright, providing fast and lightweight browser automation without needing vision models.Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to automate and interact with web pages via structured accessibility snapshots, bypassing screenshots and vision models.Apache 2.0