replywizard-whatsapp-mcp 0.2.3 → 0.2.5

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.
package/README.md CHANGED
@@ -40,10 +40,11 @@ extension** (the hub only sees tool arguments and results).
40
40
 
41
41
  ## Setup
42
42
 
43
- > **Recommended: the multi-agent connector.** Point your client at `rw-mcp-connector` (see
44
- > [Multiple AI assistants at once](#multiple-ai-assistants-at-once-daemon) below) so several assistants
45
- > can share one WhatsApp session. The single-client examples in this section still work but bind the
46
- > port directly — only one client at a time.
43
+ > **Multi-agent by default.** The `npx -y replywizard-whatsapp-mcp` config below runs the **connector**
44
+ > (the package's default bin), which auto-starts a shared local **daemon** — so several assistants
45
+ > (Claude Code + Cursor + Claude Desktop, …) can share one WhatsApp session at once, with no extra setup.
46
+ > See [Multiple AI assistants at once](#multiple-ai-assistants-at-once-daemon) for the architecture. Use
47
+ > the single-arg form above (not the older `-p <pkg> <bin>` form, which some clients fail to launch).
47
48
 
48
49
  Published to npm as [`replywizard-whatsapp-mcp`](https://www.npmjs.com/package/replywizard-whatsapp-mcp).
49
50
  You don't install anything by hand — your AI client runs it via `npx` (requires Node.js 18+).
@@ -73,13 +74,15 @@ claude mcp add replywizard -- npx -y replywizard-whatsapp-mcp
73
74
  `RW_MCP_PORT` is optional (defaults to `7869`); set it on both sides if you change it.
74
75
 
75
76
  > **Running from source instead?** Clone the repo, `cd mcp-host && npm install`, and point your
76
- > client at `node /absolute/path/to/mcp-host/src/index.js` rather than the `npx` command above.
77
+ > client at `node /absolute/path/to/mcp-host/src/connector.js` (multi-agent) — or
78
+ > `node .../src/index.js` for the legacy single-client, no-daemon hub.
77
79
 
78
80
  ## Multiple AI assistants at once (daemon)
79
81
 
80
- The `index.js` hub above binds the WebSocket port directly, so **only one AI client can use it at a
81
- time** (a second launch hits `EADDRINUSE`). To let several clients (Claude Code + Cursor + Claude
82
- Desktop, …) share one WhatsApp session, run the **daemon** instead:
82
+ This happens automatically with the `npx` config above: `replywizard-whatsapp-mcp` runs the connector,
83
+ which starts one shared daemon. (The legacy `index.js` hub — run directly via `node .../src/index.js` —
84
+ binds the WebSocket port itself, so **only one AI client can use it at a time**; a second launch hits
85
+ `EADDRINUSE`.) The daemon architecture:
83
86
 
84
87
  ```
85
88
  client A (HTTP) ─┐
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "replywizard-whatsapp-mcp",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Local MCP server that exposes WhatsApp Web (read + value tools) to AI clients via the Reply Wizard Chrome extension.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "replywizard-whatsapp-mcp": "src/index.js",
7
+ "replywizard-whatsapp-mcp": "src/connector.js",
8
8
  "rw-mcp-daemon": "src/daemon.js",
9
9
  "rw-mcp-connector": "src/connector.js"
10
10
  },
package/src/daemon.js CHANGED
@@ -125,8 +125,16 @@ export function createDaemon({
125
125
  });
126
126
  transport.onclose = () => { if (sid && sessions.delete(sid)) publishClients(); };
127
127
  const server = createMcpServer(bridge);
128
- await server.connect(transport);
129
- await transport.handleRequest(req, res, body);
128
+ try {
129
+ await server.connect(transport);
130
+ await transport.handleRequest(req, res, body);
131
+ } catch (e) {
132
+ // A rejected initialize (e.g. DNS-rebinding block, malformed body) must not
133
+ // leak the freshly-connected Server/transport. close() also fires onclose →
134
+ // session cleanup if it had already registered. Re-throw so handle() 500s.
135
+ try { await transport.close(); } catch { /* noop */ }
136
+ throw e;
137
+ }
130
138
  }
131
139
 
132
140
  async function handle(req, res) {
package/src/wsServer.js CHANGED
@@ -330,7 +330,13 @@ export class ExtensionBridge {
330
330
  }
331
331
 
332
332
  _send(obj) {
333
- if (this.socket && this.socket.readyState === this.socket.OPEN) this.socket.send(JSON.stringify(obj));
333
+ // Never throw out of a send: if the socket is closing mid-write, socket.send can
334
+ // throw and would otherwise unwind _dispatch, leaking a lane slot until timeout.
335
+ // Swallowing here is safe — the per-action timeout and _failAll(on-disconnect)
336
+ // both recover the in-flight entry.
337
+ try {
338
+ if (this.socket && this.socket.readyState === this.socket.OPEN) this.socket.send(JSON.stringify(obj));
339
+ } catch { /* socket closing; recovery handled by timeout / disconnect */ }
334
340
  }
335
341
 
336
342
  // Set the list of connected MCP clients (called by the daemon on session