replywizard-whatsapp-mcp 0.2.1 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replywizard-whatsapp-mcp",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
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": {
package/src/daemon.js CHANGED
@@ -89,7 +89,26 @@ export function createDaemon({
89
89
  return [`127.0.0.1:${port}`, `localhost:${port}`];
90
90
  };
91
91
 
92
+ // Relay the distinct names of currently-connected MCP clients to the extension,
93
+ // so the options page can show which AI assistants are attached. Names come from
94
+ // each client's `initialize` clientInfo (the stdio connector pumps frames raw, so
95
+ // the real client's name — "Antigravity", "Cursor", … — reaches us verbatim).
96
+ function publishClients() {
97
+ if (!bridge || typeof bridge.setConnectedClients !== 'function') return;
98
+ const seen = new Set();
99
+ const clients = [];
100
+ for (const s of sessions.values()) {
101
+ const name = (s.clientInfo && s.clientInfo.name) || 'Unknown assistant';
102
+ if (seen.has(name)) continue;
103
+ seen.add(name);
104
+ clients.push({ name, version: (s.clientInfo && s.clientInfo.version) || null });
105
+ }
106
+ bridge.setConnectedClients(clients);
107
+ }
108
+
92
109
  async function newSession(req, res, body) {
110
+ // The client's name/version live in the initialize request's clientInfo.
111
+ const clientInfo = (body && body.params && body.params.clientInfo) || null;
93
112
  // Capture the session id at init: transport.sessionId may already be cleared by
94
113
  // the time onclose fires, so we must not rely on it for cleanup.
95
114
  let sid = null;
@@ -97,9 +116,13 @@ export function createDaemon({
97
116
  sessionIdGenerator: () => randomUUID(),
98
117
  enableDnsRebindingProtection: true,
99
118
  allowedHosts: allowedHosts(),
100
- onsessioninitialized: (id) => { sid = id; sessions.set(id, { transport, server, lastSeen: now() }); },
119
+ onsessioninitialized: (id) => {
120
+ sid = id;
121
+ sessions.set(id, { transport, server, lastSeen: now(), clientInfo });
122
+ publishClients();
123
+ },
101
124
  });
102
- transport.onclose = () => { if (sid) sessions.delete(sid); };
125
+ transport.onclose = () => { if (sid && sessions.delete(sid)) publishClients(); };
103
126
  const server = createMcpServer(bridge);
104
127
  await server.connect(transport);
105
128
  await transport.handleRequest(req, res, body);
package/src/protocol.js CHANGED
@@ -45,6 +45,7 @@ export const CONTROL = Object.freeze({
45
45
  PAIRING_COMPLETE: 'pairing_complete',
46
46
  PAIRING_FAILED: 'pairing_failed',
47
47
  AUTH_SUCCESS: 'auth_success',
48
+ CLIENTS_UPDATE: 'clients_update',
48
49
  PING: 'ping',
49
50
  PONG: 'pong',
50
51
  });
package/src/wsServer.js CHANGED
@@ -113,6 +113,9 @@ export class ExtensionBridge {
113
113
  this.portConflict = false; // true if the port was already in use at startup
114
114
  // Desktop-notification fn for the pairing code (injectable for tests).
115
115
  this._notify = opts.notify ?? notifyPairingCode;
116
+ // Connected MCP clients (by name), set by the daemon and relayed to the
117
+ // extension so the options page can show which AI assistants are attached.
118
+ this.connectedClients = [];
116
119
  // Concurrency scheduler (WS-A3): all client sessions multiplex onto the single
117
120
  // extension socket. Reads and value-actions run in INDEPENDENT lanes so a slow
118
121
  // value-action (transcribe/summarize/suggest → LLM/STT) never head-of-line-blocks
@@ -192,6 +195,7 @@ export class ExtensionBridge {
192
195
  if (token && this.sessionToken && token === this.sessionToken) {
193
196
  this.paired = true;
194
197
  this._send({ method: CONTROL.AUTH_SUCCESS, params: { protocol: PROTOCOL_VERSION } });
198
+ this._sendClients(); // sync current assistants to a freshly reconnected extension
195
199
  log('Reconnected with a valid session token (no pairing needed).');
196
200
  } else {
197
201
  this.pairingCode = sixDigitCode();
@@ -218,6 +222,7 @@ export class ExtensionBridge {
218
222
  clearPairingCode();
219
223
  this._send({ method: CONTROL.PAIRING_COMPLETE, params: { session_id: randomUUID(), session_token: this.sessionToken } });
220
224
  this._send({ method: CONTROL.AUTH_SUCCESS, params: {} });
225
+ this._sendClients(); // sync current assistants right after pairing
221
226
  log('Pairing approved.');
222
227
  } else {
223
228
  // Tell the extension so it can show "incorrect code" instead of just
@@ -328,6 +333,18 @@ export class ExtensionBridge {
328
333
  if (this.socket && this.socket.readyState === this.socket.OPEN) this.socket.send(JSON.stringify(obj));
329
334
  }
330
335
 
336
+ // Set the list of connected MCP clients (called by the daemon on session
337
+ // open/close) and relay it to the extension. Idempotent and safe to call when
338
+ // no extension is connected (the _send is a no-op then; re-sent on next auth).
339
+ setConnectedClients(clients) {
340
+ this.connectedClients = Array.isArray(clients) ? clients : [];
341
+ this._sendClients();
342
+ }
343
+
344
+ _sendClients() {
345
+ this._send({ method: CONTROL.CLIENTS_UPDATE, params: { clients: this.connectedClients } });
346
+ }
347
+
331
348
  // Reject every queued and in-flight action (e.g. on disconnect / shutdown).
332
349
  _failAll(err) {
333
350
  for (const lane of Object.values(this.lanes)) {