cypress-mcp

cypress-mcp

Exposes Cypress as AI-usable tools for running tests, managing spec files, taking accessibility snapshots, and automating a browser via Playwright-core.

Category
访问服务器

README

cypress-mcp

MCP server for Cypress — let AI agents run tests, manage specs, snapshot pages, and automate browsers.

npm version License: MIT Tested with Vitest


What is this?

cypress-mcp is a Model Context Protocol server that exposes Cypress as a set of AI-usable tools. Connect it to Claude, Cursor, VS Code, or any MCP client and let your AI assistant:

  • Run your Cypress tests and get structured pass/fail results
  • Read and write spec files — generate new tests from natural language
  • Snapshot any page via the ARIA accessibility tree — no screenshots needed
  • Automate a browser — navigate, click, type, evaluate JavaScript

Think of it as the Cypress equivalent of @playwright/mcp.


How it works

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)

Browser automation uses a separate Playwright-core instance — not the Cypress browser — keeping automation and testing concerns cleanly separated.


Quick Start

1. Install browsers (one-time)

npx playwright install chromium

2. Connect to your MCP client

Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

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

VS Code / Cursor (HTTP/SSE mode):

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

Then point your MCP client at http://localhost:8932/sse.

3. Start asking your 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

Tools

Spec file tools

Tool Description
cypress_list_specs List all spec files matching Cypress patterns
cypress_read_spec Read a spec file's contents
cypress_write_spec Create or overwrite a spec file
cypress_get_config Read cypress.config.ts/js

Test runner tools

Tool Description
cypress_run Run tests — returns pass/fail counts and error details
cypress_open Open Cypress GUI
cypress_get_last_run Read results from the last run

Browser automation tools

Tool Description
cypress_navigate Navigate to a URL
cypress_snapshot Get ARIA accessibility tree of the page
cypress_screenshot Take a screenshot (full page or element)
cypress_click Click an element by selector or text
cypress_type Type into an input field
cypress_evaluate Run JavaScript and return the result
cypress_get_url Get the current URL
cypress_wait_for Wait for an element or text to appear
cypress_close_browser Close the automation browser

Example workflow

Here's what happens when you ask an AI to write tests for your app:

1. Snapshot the pagecypress_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 writes a speccypress_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. Run the testscypress_run

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

CLI Options

cypress-mcp [options]

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

Running Locally

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

Development mode

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

Requirements

Requirement Version
Node.js >= 18
Cypress (in your project) >= 12
Chromium (for browser tools) via npx playwright install chromium

Cypress is a peer dependency — install it in your project, not globally. The MCP server picks it up automatically from node_modules/.bin/cypress.


Architecture

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

Why Playwright-core for browser automation?

Cypress is a testing framework — its browser isn't accessible as a real-time automation API. Rather than try to hack into the Cypress browser, cypress-mcp runs a lightweight separate Playwright-core instance for automation tasks (navigate, snapshot, screenshot). The Cypress browser is only used when running actual tests via cypress_run.


Comparison with @playwright/mcp

Feature cypress-mcp @playwright/mcp
Browser automation ✅ (via Playwright-core) ✅ (native)
Accessibility snapshot ✅ ARIA tree ✅ ARIA tree
Run existing tests ✅ Cypress tests
Write test files .cy.ts / .cy.js
Test results parsing ✅ structured JSON
Vision / coordinate tools ❌ (coming)
Best for Teams using Cypress for E2E General browser automation

Contributing

Issues and PRs welcome. Please open an issue before starting significant work.

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

License

MIT © Yashpreet Bathla

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选