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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.