Token导航 LogoToken导航TokenDH.com
Cypress MCP logo
浏览器工具stdio官方级别未说明来源级核验

Cypress MCP

MCP Server

playwright

cypress-mcp是一个基于Cypress的MCP服务器,允许AI代理运行测试、管理规范文件、快照页面和自动化浏览器操作。

工具数

16

提示词数

0

GitHub Stars

5

资源数

0
测试自动化浏览器自动化TypeScriptClaudeClaudeCursorVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

yashpreetbathla

提供方

yashpreetbathla

最后核验

2026/5/17 20:22

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx playwright install chromium

详细介绍

柏树mcp

Cypress的MCP服务器——让AI代理运行测试、管理规范、快照页面和自动化浏览器。

](https://www.npmjs.com/package/cypress-mcp) ![License: MIT](LICENSE) ![Tested with Vitest](https://vitest.dev)

______________________________________________________________________

这是什么?

cypress-mcp 是一个 模型上下文协议 服务器,将Cypress作为一组AI可用工具公开。将其连接到Claude、Cursor、VS Code或任何MCP客户端,让您的AI助手:

  • 运行Cypress测试 并获得结构化的通过/失败结果
  • 读写规范文件 --从自然语言生成新测试
  • 快照任何页面 通过ARIA可访问性树——无需截图
  • 自动化浏览器 --导航、单击、键入、评估JavaScript

把它想象成赛普拉斯的等价物 @playwright/mcp.

______________________________________________________________________

运作原理

Your AI (Claude / Cursor / VS Code)
        │
        │  MCP protocol (stdio or HTTP/SSE)
        ▼
   cypress-mcp server
        │
        ├── Spec tools ──────────► Filesystem (list / read / write .cy.ts files)
        ├── Runner tools ─────────► Cypress CLI (run tests, open GUI, get results)
        └── Browser tools ────────► Playwright-core (navigate, snapshot, screenshot)

浏览器自动化使用一个单独的Playwright核心实例,而不是Cypress浏览器,将自动化和测试问题清晰地分开。

______________________________________________________________________

快速开始

1.安装浏览器(一次性)

npx playwright install chromium

2.连接到您的MCP客户端

克劳德桌面版 (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "cypress": {
      "command": "npx",
      "args": ["cypress-mcp", "--project", "/path/to/your/app"]
    }
  }
}

VS代码/光标 (HTTP/SSE模式):

npx cypress-mcp --port 8932 --project /path/to/your/app

然后将您的MCP客户端指向 http://localhost:8932/sse.

3.开始问你的AI

> List the spec files in my project
> Navigate to http://localhost:3000/login and take a snapshot
> Write a Cypress test for the login form based on what you see
> Run the login spec and tell me what failed

______________________________________________________________________

工具

规范文件工具

工具说明
cypress_list_specs列出所有与Cypress图案匹配的规格文件
cypress_read_spec读取规范文件的内容
cypress_write_spec创建或覆盖规范文件
cypress_get_config阅读 cypress.config.ts/js

测试流道工具

工具说明
cypress_run运行测试--返回通过/失败计数和错误详细信息
cypress_open打开Cypress图形用户界面
cypress_get_last_run读取上次运行的结果

浏览器自动化工具

工具说明
cypress_navigate导航到URL
cypress_snapshot获取页面的ARIA可访问性树
cypress_screenshot截图(整页或元素)
cypress_click按选择器或文本单击元素
cypress_type在输入字段中键入
cypress_evaluate运行JavaScript并返回结果
cypress_get_url获取当前URL
cypress_wait_for等待元素或文本出现
cypress_close_browser关闭自动化浏览器

______________________________________________________________________

工作流程示例

以下是当你要求人工智能为你的应用程序编写测试时会发生的情况:

1.快照页面cypress_navigate + cypress_snapshot

Accessibility Snapshot:
- heading "My Todo List" [level=1]
- textbox "New todo"
- button "Add"
- list "Todo list"
  - listitem: No todos yet. Add one above!

2.AI编写规范cypress_write_spec

describe('Todo App', () => {
  it('adds a new todo', () => {
    cy.visit('http://localhost:4000');
    cy.get('[aria-label="New todo"]').type('Buy groceries');
    cy.get('button').contains('Add').click();
    cy.get('#todo-list').should('contain', 'Buy groceries');
  });
});

3.运行测试cypress_run

✅ Cypress Run PASSED
Tests:    10
Passed:   10
Failed:   0
Duration: 3.21s

______________________________________________________________________

CLI选项

cypress-mcp [options]

  --project 
    Cypress project root (default: current directory)
  --port      Start HTTP/SSE server instead of stdio
  --browser     Browser for automation: chromium | firefox | webkit (default: chromium)
  --headed            Show the automation browser window
  --help              Show help
  --version           Show version

______________________________________________________________________

本地运行

git clone https://github.com/yashpreetbathla/cypress-mcp.git
cd cypress-mcp
npm install
npx playwright install chromium
npm run build
npm test

开发模式

npm run dev        # TypeScript watch mode
npm test           # Run unit tests (Vitest)
npm run test:watch # Watch mode

______________________________________________________________________

需求

要求版本
Node.js>=18
Cypress(在您的项目中)>=12
Chromium(用于浏览器工具)通过 npx playwright install chromium

柏树是一种 对等依赖 --在项目中安装它,而不是全局安装。MCP服务器自动从 node_modules/.bin/cypress.

______________________________________________________________________

建筑

cypress-mcp/
├── src/
│   ├── index.ts          CLI entry point
│   ├── server.ts         MCP server (stdio + HTTP/SSE transports)
│   ├── context.ts        Playwright-core browser context singleton
│   ├── toolHandler.ts    Central tool dispatcher
│   ├── tools/
│   │   ├── specs.ts      Spec file management (filesystem)
│   │   ├── runner.ts     Cypress test execution (CLI)
│   │   └── browser.ts    Browser automation (Playwright-core)
│   ├── types.ts          TypeScript interfaces
│   └── version.ts        Version constant
└── tests/
    └── unit/
        ├── specs.test.ts      13 tests for file tools
        ├── tools.test.ts       8 tests for tool definitions
        └── toolHandler.test.ts 4 tests for dispatch logic

为什么Playwright是浏览器自动化的核心?

Cypress是一个测试框架-它的浏览器不能作为实时自动化API访问。与其试图侵入Cypress浏览器, cypress-mcp 运行一个轻量级的独立Playwright核心实例,用于自动化任务(导航、快照、截图)。Cypress浏览器仅在通过以下方式运行实际测试时使用 cypress_run.

______________________________________________________________________

与@description/mcp的比较

特点cypress-mcp@playwright/mcp
浏览器自动化✅ (通过剧作家核心)✅ (本地)
辅助功能快照✅ ARIA树✅ ARIA树
运行现有测试✅ 柏树测试
写入测试文件.cy.ts / .cy.js
测试结果解析✅ 结构化JSON
视觉/坐标工具❌ (即将到来)
最适合使用Cypress进行E2E的团队通用浏览器自动化

______________________________________________________________________

贡献

欢迎发布问题和PR。请在开始重要工作之前打开一个问题。

npm test             # must pass
npm run build        # must compile cleanly

______________________________________________________________________

许可证

MIT© 雅什普里特巴特拉

目录标签

目录标签

测试自动化浏览器自动化TypeScriptClaude本地部署AI辅助测试Cypress工具

支持客户端

ClaudeCursorVS Code

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

session

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

playwright

工具数量(toolCount,工具数)

16

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiosession部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP