MSW Agent Tools — Live API mocking for AI agents and developers
Control your mocks,
live.
msw-cli and msw-mcp let AI agents and developer tools update Mock Service Worker handlers in the browser in real time — no page reload, no server restart.
Everything you need for dynamic mocking
Purpose-built for AI-assisted development workflows and agent-driven testing scenarios.
Agent-Friendly CLI
Open a session, add handlers — just like Playwright. Any AI agent or script can drive mocks with simple shell commands, no MCP required.
Zero-Reload Updates
Handlers update live in the browser via WebSocket. Never restart your dev server just to change a mock response.
Session Management
Isolated named sessions per project directory. List, close, and manage concurrent environments without conflicts.
MCP Integration
AI assistants in Cursor, Claude Code, and VS Code can call msw_add_handlers directly via the Model Context Protocol.
Framework Agnostic
Works with React, Vue, Svelte, vanilla JS — any framework that supports MSW 2.x service workers.
Handler Persistence
Optionally persist dynamic handlers across page refreshes via localStorage. FIFO limit keeps storage clean.
CLI or MCP — your choice
Both share the same WebSocket core. Pick the integration that fits your workflow.
msw-cli
A Playwright-style CLI for any agent or script. Open a session, then add, update, remove, or reset handlers with plain shell commands.
# 1. Start the daemon
$ msw-cli open
# 2. Add a mock
$ msw-cli add \
"http.get('/api/user', () => HttpResponse.json({ id: 1 }))"
# 3. Check status
$ msw-cli status
# 4. Close when done
$ msw-cli close msw-cli docs → msw-mcp
A Model Context Protocol server. Register it once in your MCP client and let your AI assistant manage mocks directly.
// .cursor/mcp.json
{
"mcpServers": {
"msw-mcp": {
"command": "npx",
"args": ["msw-mcp@latest"]
}
}
}
// Then ask your AI assistant:
"Mock GET /api/users to return 500" msw-mcp docs →