@msw-dev-tool/node-cli
v0.2.1
Published
CLI for AI agents to programmatically control msw-dev-tool Node sessions via session snapshot files. Not a general-purpose interactive TUI — designed for machine-readable, one-shot commands.
Readme
@msw-dev-tool/node-cli
CLI for AI agents to programmatically control msw-dev-tool in Node.js.
This package is not a human-oriented interactive TUI. It is designed for machine-readable, one-shot commands that AI agents (and scripts) can call.
How it works
- Your app calls
setupDevToolServer()from@msw-dev-tool/core/node. - That process owns
SetupServerand writes a session snapshot file (like browsersessionStorage). - This CLI reads/writes that snapshot. The owner process polls and applies changes to MSW.
The CLI never mutates another process's in-memory store directly.
Install
pnpm add -D @msw-dev-tool/node-cli @msw-dev-tool/core mswSession discovery
--session <path>MSW_DEV_TOOL_SESSIONenv.msw-dev-tool/sessionpointer in the current working directory
Commands
All commands print JSON to stdout.
msw-dev-tool session
msw-dev-tool list
msw-dev-tool get '<id>'
msw-dev-tool set-behavior '<id>' delay
msw-dev-tool add-temp --json '{"path":"/api/tmp","method":"get","contentType":"application/json","status":"200","response":"{\"ok\":true}"}'
msw-dev-tool remove-temp '<id>'
msw-dev-tool resetExample (app)
import { setupDevToolServer } from "@msw-dev-tool/core/node";
import { handlers } from "./handlers";
const server = await setupDevToolServer(...handlers);
server.listen();Then from another process / AI agent:
msw-dev-tool list
msw-dev-tool set-behavior '{"path":"/api/user","method":"get"}' "network error"After changing handler code, run msw-dev-tool reset and wait for ok before further commands. Writes during an in-flight reset can be discarded when the owner reseeds; the CLI settles ~300ms so ok usually means apply finished.
