cypress-mcp
MCP server plugin for Cypress that enables AI agents to control a browser for automated testing and interaction.
README
cypress-mcp
MCP (Model Context Protocol) server plugin for Cypress — let AI agents control your browser for testing.
Turn Cypress into an MCP server that AI clients (Claude Desktop, Cursor, Windsurf, etc.) can use to navigate, interact with, and test web applications.
Features
- 52 browser automation tools — navigate, click, type, screenshot, intercept network, iframes, and more
- Accessibility-first DOM snapshots — ARIA-based page representation optimized for LLM understanding
- Zero config — just 2 lines to integrate into your Cypress project
- Network interception — capture, filter, and mock HTTP requests
- Test generation — automatically generate Cypress tests from recorded sessions
- Plugin system — extend with custom tools via third-party plugins
- MCP standard — works with any MCP-compatible AI client
Quick Start
Install
npm install cypress-mcp --save-dev
Configure (2 lines)
cypress.config.ts:
import { defineConfig } from 'cypress';
import { cypressMcp } from 'cypress-mcp/plugin';
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000', // your app
setupNodeEvents(on, config) {
cypressMcp(on, config);
return config;
},
},
});
cypress/support/e2e.ts:
import 'cypress-mcp/support';
Run
# Auto-detects baseUrl from cypress.config
npx cypress-mcp
# Or override baseUrl for a specific project
npx cypress-mcp --base-url http://localhost:4200
# All options
npx cypress-mcp --base-url http://localhost:3000 --browser chrome --port 3457 --debug
Connect to MCP Clients
Claude Desktop — add to claude_desktop_config.json:
{
"mcpServers": {
"cypress": {
"command": "npx",
"args": ["cypress-mcp"]
}
}
}
baseUrl is auto-detected from cypress.config.ts in the working directory. To override:
{
"mcpServers": {
"cypress": {
"command": "npx",
"args": ["cypress-mcp", "--base-url", "http://localhost:4200"],
"env": {
"CYPRESS_BASE_URL": "http://localhost:4200"
}
}
}
}
VS Code / Cursor:
{
"mcpServers": {
"cypress": {
"command": "npx",
"args": ["cypress-mcp", "--base-url", "http://localhost:3000"]
}
}
}
Claude Code:
claude mcp add cypress npx cypress-mcp --base-url http://localhost:3000
baseUrl Resolution Order
The CLI resolves baseUrl from multiple sources (highest priority first):
--base-urlCLI argumentCYPRESS_BASE_URLenvironment variable- Auto-detected from
cypress.config.{ts,js}in current directory - No baseUrl (Cypress works without it — use
browser_navigateto go anywhere)
Tools (38 total)
Navigation (4)
| Tool | Description |
|---|---|
browser_navigate |
Navigate to a URL |
browser_go_back |
Go back in history |
browser_go_forward |
Go forward in history |
browser_reload |
Reload the page |
Interaction (9)
| Tool | Description |
|---|---|
browser_click |
Click an element (left/right/double) |
browser_type |
Type text with keystroke simulation |
browser_fill |
Set input value directly |
browser_select |
Select dropdown option |
browser_check |
Check/uncheck checkbox or radio |
browser_hover |
Hover over element |
browser_scroll |
Scroll page or element into view |
browser_drag_drop |
Drag and drop elements |
browser_press_key |
Press keyboard keys |
Snapshot & DOM (4)
| Tool | Description |
|---|---|
browser_snapshot |
Core tool — accessibility tree snapshot |
browser_query_elements |
Find elements by role, text, state |
browser_get_text |
Get element or page text content |
browser_get_attribute |
Get HTML attribute values |
Network (5)
| Tool | Description |
|---|---|
browser_network_requests |
List captured requests |
browser_network_request |
Get full request details |
browser_mock_route |
Mock a network endpoint |
browser_remove_mock |
Remove a mock |
browser_wait_for_request |
Wait for a specific request |
Screenshot & Visual (2)
| Tool | Description |
|---|---|
browser_screenshot |
Capture screenshot (element or page) |
browser_viewport |
Set viewport size/preset |
Console & Debug (2)
| Tool | Description |
|---|---|
browser_console_messages |
Get console log/warn/error |
browser_evaluate |
Execute JavaScript in browser |
Tab Management (4)
| Tool | Description |
|---|---|
browser_list_tabs |
List open tabs (emulated) |
browser_new_tab |
Open new tab |
browser_switch_tab |
Switch to tab |
browser_close_tab |
Close tab |
Storage & Cookies (5)
| Tool | Description |
|---|---|
browser_get_cookies |
Get cookies |
browser_set_cookie |
Set a cookie |
browser_clear_cookies |
Clear cookies |
browser_local_storage |
Get/set/delete localStorage |
browser_session_storage |
Get/set/delete sessionStorage |
Dialog (1)
| Tool | Description |
|---|---|
browser_handle_dialog |
Handle alert/confirm/prompt |
Utility (4)
| Tool | Description |
|---|---|
browser_wait |
Wait for condition/time/element |
browser_assert |
Assert element state |
browser_run_cypress |
Execute raw Cypress commands |
browser_generate_test |
Generate test from session history |
Architecture
┌─────────────────┐ stdio/SSE ┌─────────────────┐
│ AI Client │ ◄──────────────► │ MCP Server │
│ (Claude, etc.) │ │ (Node.js) │
└─────────────────┘ │ │
│ 38 Tool │
│ Handlers │
│ │
│ State Manager │
└────────┬────────┘
│ cy.task()
│ (polling)
┌────────┴────────┐
│ Cypress Browser │
│ │
│ Agent Loop │
│ DOM Snapshotter│
│ Net Interceptor│
│ Console Hook │
└─────────────────┘
3-Layer Architecture:
- MCP Server (Node.js) — Handles MCP protocol, tool registration, request routing
- Bridge — cy.task() based polling between Node.js and Cypress browser
- Cypress Runtime — Agent spec keeps browser open, executes commands, captures state
Options
cypressMcp(on, config, {
wsPort: 3456, // Bridge port
transport: 'stdio', // 'stdio' or 'sse'
ssePort: 3100, // SSE port (if transport === 'sse')
debug: false, // Debug logging
});
How it Works
cypressMcp()starts an MCP server (stdio) and registers 38 tool handlers- Cypress runs an "agent spec" that keeps the browser open in a polling loop
- When the AI client calls a tool (e.g.,
browser_navigate), the MCP server queues a command - The browser-side agent polls for commands via
cy.task('mcpBridgePoll') - Commands execute as real Cypress commands (
cy.visit,cy.click, etc.) - Results flow back through
cy.task('mcpBridgeResponse')
Security
See SECURITY.md for security considerations, especially regarding browser_evaluate and browser_run_cypress tools.
Important: This tool is for development/testing only. Do not expose the MCP server to untrusted networks.
Requirements
- Node.js >= 18
- Cypress >= 12.0.0
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。