@0x1f320.sh/why-did-you-render-mcp 1.1.0-dev.7 → 1.1.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +42 -14
  2. package/package.json +6 -1
package/README.md CHANGED
@@ -28,7 +28,7 @@ The **client** runs inside your React app alongside `why-did-you-render`. Whenev
28
28
  ## Installation
29
29
 
30
30
  ```sh
31
- npm install @0x1f320.sh/why-did-you-render-mcp @welldone-software/why-did-you-render
31
+ npm install @0x1f320.sh/why-did-you-render-mcp@latest @welldone-software/why-did-you-render
32
32
  ```
33
33
 
34
34
  ## Setup
@@ -65,7 +65,7 @@ const { notifier } = buildOptions({
65
65
  <summary>Claude Code</summary>
66
66
 
67
67
  ```sh
68
- claude mcp add why-did-you-render -- npx -y @0x1f320.sh/why-did-you-render-mcp
68
+ claude mcp add why-did-you-render -- npx -y @0x1f320.sh/why-did-you-render-mcp@latest
69
69
  ```
70
70
 
71
71
  </details>
@@ -74,7 +74,7 @@ claude mcp add why-did-you-render -- npx -y @0x1f320.sh/why-did-you-render-mcp
74
74
  <summary>Claude Desktop</summary>
75
75
 
76
76
  ```sh
77
- claude mcp add-json why-did-you-render '{"command":"npx","args":["-y","@0x1f320.sh/why-did-you-render-mcp"]}' -s user
77
+ claude mcp add-json why-did-you-render '{"command":"npx","args":["-y","@0x1f320.sh/why-did-you-render-mcp@latest"]}' -s user
78
78
  ```
79
79
 
80
80
  Or manually edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) / `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
@@ -84,7 +84,7 @@ Or manually edit `~/Library/Application Support/Claude/claude_desktop_config.jso
84
84
  "mcpServers": {
85
85
  "why-did-you-render": {
86
86
  "command": "npx",
87
- "args": ["-y", "@0x1f320.sh/why-did-you-render-mcp"]
87
+ "args": ["-y", "@0x1f320.sh/why-did-you-render-mcp@latest"]
88
88
  }
89
89
  }
90
90
  }
@@ -96,7 +96,7 @@ Or manually edit `~/Library/Application Support/Claude/claude_desktop_config.jso
96
96
  <summary>Cursor</summary>
97
97
 
98
98
  ```sh
99
- cursor --add-mcp '{"name":"why-did-you-render","command":"npx","args":["-y","@0x1f320.sh/why-did-you-render-mcp"]}'
99
+ cursor --add-mcp '{"name":"why-did-you-render","command":"npx","args":["-y","@0x1f320.sh/why-did-you-render-mcp@latest"]}'
100
100
  ```
101
101
 
102
102
  Or add to `.cursor/mcp.json` in your project:
@@ -106,7 +106,7 @@ Or add to `.cursor/mcp.json` in your project:
106
106
  "mcpServers": {
107
107
  "why-did-you-render": {
108
108
  "command": "npx",
109
- "args": ["-y", "@0x1f320.sh/why-did-you-render-mcp"]
109
+ "args": ["-y", "@0x1f320.sh/why-did-you-render-mcp@latest"]
110
110
  }
111
111
  }
112
112
  }
@@ -124,7 +124,7 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
124
124
  "mcpServers": {
125
125
  "why-did-you-render": {
126
126
  "command": "npx",
127
- "args": ["-y", "@0x1f320.sh/why-did-you-render-mcp"]
127
+ "args": ["-y", "@0x1f320.sh/why-did-you-render-mcp@latest"]
128
128
  }
129
129
  }
130
130
  }
@@ -136,7 +136,7 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
136
136
  <summary>VS Code (GitHub Copilot)</summary>
137
137
 
138
138
  ```sh
139
- code --add-mcp '{"name":"why-did-you-render","command":"npx","args":["-y","@0x1f320.sh/why-did-you-render-mcp"]}'
139
+ code --add-mcp '{"name":"why-did-you-render","command":"npx","args":["-y","@0x1f320.sh/why-did-you-render-mcp@latest"]}'
140
140
  ```
141
141
 
142
142
  Or add to `.vscode/mcp.json` in your project:
@@ -146,7 +146,7 @@ Or add to `.vscode/mcp.json` in your project:
146
146
  "servers": {
147
147
  "why-did-you-render": {
148
148
  "command": "npx",
149
- "args": ["-y", "@0x1f320.sh/why-did-you-render-mcp"]
149
+ "args": ["-y", "@0x1f320.sh/why-did-you-render-mcp@latest"]
150
150
  }
151
151
  }
152
152
  }
@@ -163,11 +163,16 @@ Once both the MCP server and your React dev server are running, interact with yo
163
163
  | Tool | Description |
164
164
  | --- | --- |
165
165
  | `get_renders` | Returns all captured unnecessary re-renders, including stack traces. Optionally filter by `component` name. |
166
- | `get_render_summary` | Returns a summary of re-renders grouped by component with counts. |
166
+ | `get_render_summary` | Returns a summary of re-renders grouped by component with counts and durations. |
167
167
  | `get_commits` | Lists React commit IDs that have recorded render data. Use these IDs with `get_renders_by_commit`. |
168
168
  | `get_renders_by_commit` | Returns all unnecessary re-renders for a specific React commit ID, including stack traces. |
169
169
  | `get_tracked_components` | Lists components currently tracked by why-did-you-render. |
170
170
  | `get_projects` | Lists all active projects (identified by their origin URL). |
171
+ | `save_snapshot` | Saves the current render summary as a named snapshot for later comparison. |
172
+ | `list_snapshots` | Lists all saved render snapshots with their timestamps. |
173
+ | `compare_snapshots` | Compares two saved render snapshots and shows per-component render count changes. |
174
+ | `delete_snapshot` | Deletes a saved render snapshot by name. |
175
+ | `wait_for_renders` | Waits for new renders after code changes (e.g. HMR), with configurable timeout. |
171
176
  | `clear_renders` | Clears all stored render data. Optionally scope to a specific project. |
172
177
  | `pause_renders` | Pauses render data collection in the browser. Clients stop reporting until resumed. |
173
178
  | `resume_renders` | Resumes render data collection previously paused with `pause_renders`. |
@@ -193,6 +198,26 @@ Each frame has the following structure:
193
198
 
194
199
  Agents can use `stackFrames` to pinpoint the exact source location of each unnecessary re-render — navigating directly to the file and line that caused it, without requiring manual browser inspection.
195
200
 
201
+ ### Snapshots
202
+
203
+ Snapshots let agents capture the current render summary at a point in time and compare it against a later state. This is useful for measuring whether a code change actually reduced unnecessary re-renders:
204
+
205
+ 1. Call `save_snapshot` with a name (e.g. `"before-fix"`)
206
+ 2. Make code changes and interact with the app
207
+ 3. Call `save_snapshot` with another name (e.g. `"after-fix"`)
208
+ 4. Call `compare_snapshots` to see per-component render count changes
209
+
210
+ Snapshots are stored as JSON files in `~/.wdyr-mcp/snapshots/`.
211
+
212
+ ### HMR-aware waiting
213
+
214
+ `wait_for_renders` lets agents wait for new renders after a code change. It detects HMR (Hot Module Replacement) events from both Vite and webpack, so it knows when the browser has applied the update. This enables a workflow like:
215
+
216
+ 1. Agent edits code
217
+ 2. Agent calls `wait_for_renders` (with optional timeout)
218
+ 3. Tool waits for HMR to complete and new renders to arrive
219
+ 4. Returns the new render data for analysis
220
+
196
221
  ### Commit-level grouping
197
222
 
198
223
  Each render report is tagged with a React **commit ID**, allowing agents to inspect which components re-rendered together in the same commit. The client tracks commits by hooking into `__REACT_DEVTOOLS_GLOBAL_HOOK__.onCommitFiberRoot`, which React calls synchronously once per commit. A typical workflow:
@@ -210,12 +235,15 @@ Browser (project-b) ──┤
210
235
  MCP #2 → WS(:4649) → relay client ──▶ MCP #1
211
236
 
212
237
 
213
- ~/.wdyr-mcp/renders/ (JSONL files, shared across instances)
214
- ├─ http___localhost_3000.jsonl
215
- └─ http___localhost_5173.jsonl
238
+ ~/.wdyr-mcp/
239
+ ├─ renders/ (JSONL files, shared across instances)
240
+ │ ├─ http___localhost_3000.jsonl
241
+ │ └─ http___localhost_5173.jsonl
242
+ └─ snapshots/ (JSON files, named snapshots)
243
+ └─ before-fix.json
216
244
  ```
217
245
 
218
- - **Multiple MCP instances** can run simultaneously. Only the first instance (the "owner") starts the WebSocket server; others connect as socket.io clients to relay commands (e.g. pause/resume) to the owner. All instances share the same JSONL data directory.
246
+ - **Multiple MCP instances** can run simultaneously. Only the first instance (the "owner") starts the WebSocket server; others connect as socket.io clients to relay commands (e.g. pause/resume) to the owner. All instances share the same data directories.
219
247
  - **Multi-project support** — Each project is identified by `location.origin`. Render data is stored in per-project JSONL files.
220
248
  - **No daemon required** — Each MCP instance is independent. The WebSocket server is opportunistically claimed by whichever instance starts first. Commands requiring WS access are relayed to the owner.
221
249
  - **Value dictionary deduplication** — Render reports often repeat the same `prevValue`/`nextValue` objects across thousands of entries. Each JSONL file stores a content-addressed dictionary on its first line, mapping xxhash-wasm hashes to unique values. Render lines reference them via `@@ref:<hash>` sentinels instead of inlining the full object, dramatically reducing file size. Reads hydrate refs transparently.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0x1f320.sh/why-did-you-render-mcp",
3
- "version": "1.1.0-dev.7",
3
+ "version": "1.1.1-dev.1",
4
4
  "type": "module",
5
5
  "description": "MCP server that collects why-did-you-render data from browser and exposes it to coding agents",
6
6
  "license": "MIT",
@@ -34,6 +34,11 @@
34
34
  "require": "./dist/client/index.cjs"
35
35
  }
36
36
  },
37
+ "typesVersions": {
38
+ "*": {
39
+ "client": ["./dist/client/index.d.ts"]
40
+ }
41
+ },
37
42
  "files": ["dist"],
38
43
  "scripts": {
39
44
  "build": "tsdown",