No MCP required
Works in any terminal, CI script, or agent that can run shell commands. No MCP client setup needed.
msw-cli is a command-line interface that lets you — or an AI agent — add, update, remove, and reset MSW request handlers in a running browser tab without reloading the page.
It uses the same session-based model as Playwright: open a session first, then drive handler operations against it.
┌──────────────┐ HTTP /api/tools/* ┌──────────────────────┐ WebSocket ┌──────────────────┐│ │────────────────────►│ │────────────►│ ││ msw-cli │ │ @msw-mcp/core │ │ Browser + MSW ││ (terminal) │ │ daemon (port 6789) │ │ service worker ││ │◄────────────────────│ │◄────────────│ │└──────────────┘ └──────────────────────┘ └──────────────────┘msw-cli open spawns a background daemon that starts an HTTP + WebSocket server.@msw-mcp/client) connects to the daemon over WebSocket.add, update, remove, etc.) POST to the daemon’s HTTP API, which forwards them to the browser over the open WebSocket.Session metadata (port, pid) is stored at ~/.msw-cli/sessions/.
No MCP required
Works in any terminal, CI script, or agent that can run shell commands. No MCP client setup needed.
Playwright-style sessions
Open a named session per project directory. Multiple sessions can run concurrently on different ports.
Auto port selection
If port 6789 is busy, msw-cli open auto-selects the next available port
and tells you to update your bridge URL.
Live handler evaluation
Handler code strings are evaluated in the browser context against the live MSW worker — changes take effect instantly.
# New project? Print the full scaffolding guide firstmsw-cli setup
# Start a sessionmsw-cli open
# Add a handlermsw-cli add "http.get('/api/user', () => HttpResponse.json({ id: 1 }))"
# Update an existing handlermsw-cli update "/api/user" -h "http.get('/api/user', () => HttpResponse.json({ id: 2 }))"
# Remove a handlermsw-cli remove "/api/user"
# Reset to base handlersmsw-cli reset
# Check connection and active handlersmsw-cli status
# Close the sessionmsw-cli close