Generate handlers from natural language
“Create a REST API for user management with CRUD operations” → AI writes and applies the handler code.
msw-mcp is a Model Context Protocol server that gives AI assistants — in Cursor, Claude Code, VS Code, Windsurf, and other MCP clients — the ability to add, update, remove, and inspect MSW request handlers in a live browser tab.
It shares the same WebSocket daemon as msw-cli, powered by @msw-mcp/core.
┌─────────────────┐ MCP (stdio) ┌──────────────────────┐ WebSocket ┌──────────────────┐│ │──────────────►│ │────────────►│ ││ AI assistant │ │ msw-mcp server │ │ Browser + MSW ││ (Cursor, etc.) │ │ (port 6789) │ │ service worker ││ │◄──────────────│ │◄────────────│ │└─────────────────┘ └──────────────────────┘ └──────────────────┘msw-mcp over stdio using the MCP protocol.msw-mcp embeds an HTTP + WebSocket server from @msw-mcp/core.@msw-mcp/client) connects to the WebSocket.msw_add_handlers), the server forwards the handler code over WebSocket.Generate handlers from natural language
“Create a REST API for user management with CRUD operations” → AI writes and applies the handler code.
Update existing mocks
“Make the /users endpoint return a 500 error” → AI calls
msw_update_handlers to replace the handler atomically.
Mock external APIs
“Mock the GitHub API to return fake repo data” → handlers for
api.github.com endpoints are injected into the service worker.
Inspect state
msw_get_status returns whether the browser is connected, the worker
status, and a summary of all active handlers.
| Tool | Purpose |
|------|---------|
| msw_add_handlers | Add handler code strings; optional once for one-time handlers |
| msw_update_handlers | Replace handlers matching URL patterns (atomic) |
| msw_remove_handlers | Remove handlers by URL patterns and optional HTTP methods |
| msw_reset_handlers | Clear runtime handlers or set an explicit new list |
| msw_get_status | Report browser connection and active handler list |
See MCP Tools for full parameter reference and examples.
/msw-setupThe /msw-setup prompt automatically scaffolds the frontend integration:
/msw-setupThe AI will:
msw and msw-mcp dependenciesmocks/ directory structureSee /msw-setup Prompt for details.
msw-mcp works with any MCP-compatible client that supports the stdio transport:
claude mcp add)