Cypress Mcp

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

Shows an AI assistant the last cypress run: command log, errors, screenshots, DOM of failed tests.

发布方自己的服务:Cypress Cloud MCP

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

让 AI 助手查看最近一次 Cypress 测试运行的命令日志、错误、截图和失败测试的 DOM。

可以做什么
它读取最近一次 cypress run 的结果,让助手看到每个测试执行了哪些命令、失败的错误信息、截图,以及失败时刻的 DOM 快照。工具包括 list_specs、read_spec、get_config、get_last_run、get_screenshot、query_dom 和 run_spec,其中 run_spec 可运行单个 spec 并等待完成。
适用场景
当 Cypress 测试以 headless 方式在本机或 CI 中运行时使用,让助手直接看到失败原因。若你是在打开的 Cypress 应用中边写测试边调试,官方 cypress tap 更合适。
运行要求
需要 Node.js 18+ 和 Cypress 12+,并在 cypress.config 中注册插件、在 support 文件中导入支持模块。以 npm 包 @miroslavmyrha/cypress-mcp 安装,通过 stdio 或 HTTP 连接;HTTP 模式可设置 MCP_HTTP_TOKEN。
安装前请注意
run_spec 会实际执行测试,可能触发被测应用的副作用。get_config 会读取配置文件,敏感值会被遮蔽;HTTP 模式若未设置 MCP_HTTP_TOKEN,会生成随机令牌并输出到 stderr。DOM 快照和截图会写入项目的 .cypress-mcp 目录,建议加入 .gitignore。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

cypress-mcp

[npm] [CI] [License: MIT]

MCP server that shows an AI assistant what happened in your last cypress run: which commands each test ran, what failed, the error, a screenshot, and the page as it was at the moment of the failure.

It is made for headless runs, on your machine and in CI. That is the place the official tools do not reach, see How it compares.

bash
npm install -D @miroslavmyrha/cypress-mcp

Example

A spec with three tests, the last of which fails:

js
it('shows a counter of finished items', () => {  cy.get('.todo-list li').first().find('input[type=checkbox]').check()  cy.get('[data-test=finished-count]').should('contain', '1')})

After cypress run, the assistant calls get_last_run and gets the commands that ran, the error and the path of a DOM snapshot (output shortened):

json
{  "title": "Todo list > shows a counter of finished items",  "state": "failed",  "domSnapshotPath": "snapshots/cypress-e2e-todo-cy-js/todo-list-shows-a-counter-of-finished-items-d963bb8d.html",  "commands": [    { "name": "visit", "message": "https://example.cypress.io/todo" },    { "name": "get", "message": ".todo-list li" },    { "name": "first", "message": "" },    { "name": "find", "message": "input[type=checkbox]" },    { "name": "check", "message": "" },    { "name": "get", "message": "[data-test=finished-count]" }  ],  "error": "AssertionError: Timed out retrying after 2000ms: Expected to find element: `[data-test=finished-count]`, but never found it."}

It can then look into the page as it was when the test failed. query_dom with the selector .todo-count:

json
{  "selector": ".todo-count",  "totalMatches": 1,  "results": [    {      "breadcrumb": "body > section.todoapp-wrapper > div.todoapp > footer.footer > span.todo-count",      "outerHTML": "<span class=\"todo-count\"><strong>1</strong> item left</span>"    }  ]}

So the counter exists, under another selector, and the assistant can fix the test without anyone pasting logs into the chat.

How it works

cypress run → tests run  → support/index.ts captures Cypress command log per test  → cy.task('mcpSaveTestLog') transfers logs to node side  → plugin/index.ts stores logs in memory  → after:spec → merges logs + results → writes .cypress-mcp/last-run.json
Claude → MCP server → get_last_run → reads last-run.json

How it compares

Cypress has two tools of its own for AI assistants. They cover other situations than this one.

this packagecypress tapCypress Cloud MCP
Readsthe last local cypress runa live cypress open sessionruns recorded to Cypress Cloud
Headless runs and CIyesnoonly what was recorded
Command log and DOM of a failed testyesyesno, links to Test Replay
NeedsCypress 12 or newer, a plugin and a support importCypress 15.21 or newer, a Chromium browsera Cypress Cloud account
InterfaceMCP (stdio or HTTP)command lineMCP

Use cypress tap while you write a test with the Cypress app open. Use this package when the tests run headless and the assistant should see why one failed.

The results are written in the after:spec event, which Cypress fires in run mode. In cypress open that event needs experimentalInteractiveRunEvents.

Before anything reaches the assistant, values that look like secrets are redacted, and content that comes from the tested application is marked as untrusted data.

Setup

1. Install

bash
npm install -D @miroslavmyrha/cypress-mcp

Note: the unscoped cypress-mcp name on npm belongs to an unrelated project. Always use the scoped @miroslavmyrha/cypress-mcp.

2. Register the plugin in cypress.config.ts

typescript
import { defineConfig } from 'cypress'import { cypressMcpPlugin } from '@miroslavmyrha/cypress-mcp/plugin'
export default defineConfig({  e2e: {    setupNodeEvents(on, config) {      cypressMcpPlugin(on, config)    },  },})

3. Import support in cypress/support/e2e.ts

typescript
import '@miroslavmyrha/cypress-mcp/support'

4a. Configure Claude Desktop / Claude Code (stdio transport)

In your MCP settings (~/.config/claude/claude_desktop_config.json or claude mcp add):

json
{  "mcpServers": {    "cypress": {      "command": "npx",      "args": ["-y", "@miroslavmyrha/cypress-mcp", "--project", "/absolute/path/to/your/project"]    }  }}

Or with claude mcp add:

bash
claude mcp add cypress -- npx -y @miroslavmyrha/cypress-mcp --project /absolute/path/to/your/project

4b. HTTP transport (Ollama, custom bridges)

bash
# Start MCP server in HTTP mode (random token printed to stderr)npx -y @miroslavmyrha/cypress-mcp --project /path/to/project --transport http --port 3333
# Or with a fixed token for automated deploymentsMCP_HTTP_TOKEN=$(openssl rand -hex 32) npx -y @miroslavmyrha/cypress-mcp --project /path/to/project --transport http --port 3333
# Server listens on:#   POST http://localhost:3333/mcp  → tool calls (MCP Streamable HTTP)

MCP Tools

ToolDescription
list_specsList all Cypress spec files. Optional pattern glob (default: **/*.cy.{ts,js,tsx,jsx})
read_specRead a spec file's content by relative path
get_configRead the Cypress config file (cypress.config.ts/js/mjs/cjs), secret-looking values redacted
get_last_runGet results of the last test run: states, errors, command log, DOM snapshots
get_screenshotGet a screenshot from the last run. Returns the image itself (up to 2 MB) plus path and size metadata
query_domQuery the DOM snapshot of a failed test using a CSS selector
run_specRun a single Cypress spec file and wait for completion. Returns exit code and summary

Output format of .cypress-mcp/last-run.json

json
{  "timestamp": "2026-02-18T22:00:00Z",  "specs": [    {      "spec": "cypress/e2e/login.cy.ts",      "stats": { "passes": 3, "failures": 1, "pending": 0, "skipped": 0, "duration": 5230 },      "screenshots": ["/abs/path/to/Login -- should show error (failed).png"],      "tests": [        {          "title": "Login > should login with valid credentials",          "state": "passed",          "duration": 1200,          "error": null,          "domSnapshotPath": null,          "commands": [            { "name": "visit", "message": "/login" },            { "name": "get", "message": "#email" },            { "name": "type", "message": "[email protected]" }          ],          "consoleErrors": [],          "networkErrors": []        },        {          "title": "Login > should show error on invalid password",          "state": "failed",          "duration": 800,          "error": "Timed out retrying: Expected to find element: .error-message",          "domSnapshotPath": "snapshots/cypress-e2e-login-cy-ts/login--should-show-error-a1b2c3.html",          "commands": [...],          "consoleErrors": ["Uncaught TypeError: Cannot read property 'x' of null"],          "networkErrors": [{ "method": "POST", "url": "/api/login", "status": 500 }]        }      ]    },    {      "spec": "cypress/e2e/dashboard.cy.ts",      "stats": { ... },      "screenshots": [],      "tests": [...]    }  ]}

All specs from a run are captured. In cypress run the accumulator resets on before:run. In cypress open results accumulate for the lifetime of the Cypress process. Failed tests include a domSnapshotPath pointing to an HTML file (up to 100 KB of document.body.outerHTML) stored under .cypress-mcp/snapshots/.

CLI options

Options:  --project <path>     Cypress project root (default: current directory)  --transport <type>   stdio or http (default: stdio)  --port <number>      HTTP port, only for --transport http (default: 3333)  -V, --version        Show version  -h, --help           Show help

Add .cypress-mcp to .gitignore

gitignore
.cypress-mcp/

Environment variables

VariableDescription
MCP_HTTP_TOKENSet a fixed bearer token for HTTP transport (min 32 chars). If not set, a random token is generated on each start and printed to stderr.

Development

This project uses Bun as the package manager:

bash
bun installbun run typecheckbun run testbun run build

Requirements

  • Node.js 18+
  • Cypress 12+ (developed and tested with Cypress 13)

Author

Miroslav Myrha

License

MIT

来源:README.md,提交 f6b9153

工具

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

版本历史

1
  1. v0.1.2最新Oct 13, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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

其他 Cypress 集成