msw-mcp
AGENTS.md81 starsChanged 5 months agoMITView on GitHub
This project is a monorepo managed by pnpm and Turborepo. It is designed to house multiple packages related to MSW (Mock Service Worker) and MCP (Model Context Protocol). The repo uses Vitest (v4.x). Test dependencies live in the root package.json; each package has its own vitest.config.ts and "test" script. Add or update tests whenever you change behavior — new features, bug fixes, refactors, or CLI/MCP tool output. Skip tests only for docs-only or purely cosmetic changes. CI runs pnpm run…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 33,398 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .cursor/rules/testing.mdcCursor rule
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 34
Add or update tests whenever you change behavior — new features, bug fixes, refactors, or CLI/MCP tool output.
- Very specific: line 39
Build: Test files are excluded from tsc output via each package's tsconfig.json exclude.
- Very specific: line 41
Style: Prefer unit tests with injected/mocked dependencies.
- Very specific: line 42
Scope: Test real behavior and edge cases — not trivial getters or framework wiring.
- Very specific: line 65
Workspaces: Always perform actions from the root using pnpm and turbo.
- Very specific: line 66
Dependencies: Add shared devDependencies to the root package.json.
- Very specific: line 67
Code Style: Follow the Prettier configuration.
- Very specific: line 68
Builds: Use pnpm run build to ensure all packages compile correctly.
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Monorepo Overview
This project is a monorepo managed by pnpm and Turborepo. It is designed to house multiple packages related to MSW (Mock Service Worker) and MCP (Model Context Protocol).
Tooling
- Package Manager: pnpm (Workspaces)
- Build System: Turborepo
- Linting & Formatting: Prettier, lint-staged, Husky
- Language: TypeScript
Structure
packages/: Contains the individual workspace packages.msw-mcp: The core MCP server for MSW AI interaction.
package.json(root): Orchestrates the workspace, shared dependencies, and scripts.turbo.json: Defines the task pipeline and caching strategy.
Common Commands
pnpm install: Install all dependencies across the workspace.pnpm run build: Build all packages using Turbo.pnpm run test: Run all package tests via Turbo.pnpm run test:coverage: Run tests with v8 coverage reporting.pnpm run format: Format the entire codebase.pnpm turbo run <task>: Run specific Turbo tasks.
Testing
The repo uses Vitest (v4.x). Test dependencies live in the root package.json; each package has its own vitest.config.ts and "test" script.
When to add tests
Add or update tests whenever you change behavior — new features, bug fixes, refactors, or CLI/MCP tool output. Skip tests only for docs-only or purely cosmetic changes.
Conventions
- Location: Co-locate tests as
src/**/*.test.tsnext to the code they cover. - Build: Test files are excluded from
tscoutput via each package'stsconfig.jsonexclude. - Environment: Node for
core,msw-cli, andmsw-mcp;jsdomfor@msw-mcp/client(browser APIs). - Style: Prefer unit tests with injected/mocked dependencies. Use integration tests sparingly for real WebSocket/HTTP round-trips (see
packages/core/src/server.integration.test.ts). - Scope: Test real behavior and edge cases — not trivial getters or framework wiring. Mock
console.errorwhen exercising expected error paths to keep output clean.
Package-specific notes
| Package | What to test | Mocking tips |
@msw-mcp/core | SessionManager, ConnectionManager, loadMswSetupPrompt, WSServer integration | Fake WebSocket clients, vi.spyOn(os, 'homedir'), fake timers for timeouts |
@msw-mcp/client | MSWWebSocketBridge message routing, pattern matching, persistence | Mock window.msw, fake MSW worker (use/resetHandlers) |
msw-cli | Pure helpers in src/helpers.ts | Import helpers directly — do not import index.ts (triggers CLI parse) |
msw-mcp | Tool factories in src/tools/ | Inject a fake wsServer with stubbed sendMessage |
Running tests
pnpm run test # all packages
pnpm --filter @msw-mcp/core exec vitest run # single package
pnpm --filter @msw-mcp/core exec vitest run --coverageCI runs pnpm run build then pnpm run test (see .github/workflows/ci.yml).
Development Guidelines
- Workspaces: Always perform actions from the root using
pnpmandturbo. - Dependencies: Add shared devDependencies to the root
package.json. Package-specific dependencies go into the package'spackage.json. - Code Style: Follow the Prettier configuration. Use
pnpm run formatbefore committing. - Builds: Use
pnpm run buildto ensure all packages compile correctly. - TypeScript: The project uses TypeScript. Ensure types are correct and avoid
anyor@ts-ignoreunless absolutely necessary.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

