mcp-chat-connect 1.1.0 → 1.1.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.
Files changed (2) hide show
  1. package/index.js +10 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,6 +4,7 @@ const http = require('http');
4
4
  const { URL } = require('url');
5
5
  const fs = require('fs');
6
6
  const path = require('path');
7
+ const crypto = require('crypto');
7
8
  const WebSocket = require('ws');
8
9
 
9
10
  // Config file stores auth state between sessions
@@ -78,7 +79,7 @@ let wsReconnectTimeout = null;
78
79
  function connectWebSocket() {
79
80
  if (!sessionState.connected || !sessionState.token || !sessionState.channelId) return;
80
81
 
81
- const wsUrl = `${MCP_CHAT_URL.replace('https://', 'wss://').replace('http://', 'ws://')}/ws?token=${sessionState.token}&channel=${sessionState.channelId}&session=mcp-cli`;
82
+ const wsUrl = `${MCP_CHAT_URL.replace('https://', 'wss://').replace('http://', 'ws://')}/ws?token=${sessionState.token}&channel=${sessionState.channelId}&session=${sessionState.sessionToken}`;
82
83
 
83
84
  if (wsConnection) {
84
85
  try { wsConnection.close(); } catch {}
@@ -107,6 +108,11 @@ function connectWebSocket() {
107
108
  timestamp: msg.created_at || new Date().toISOString(),
108
109
  });
109
110
  } else if (data.type === 'presence') {
111
+ // Only push presence for Claude Code sessions (have session_token), not browser refreshes
112
+ if (!data.session_token) return;
113
+ // Don't push own presence events
114
+ if (data.user_id === sessionState.userId) return;
115
+
110
116
  pushChannelMessage('mcp-chat', `${data.user_name} ${data.status} #${sessionState.channelName}`, {
111
117
  channel: sessionState.channelName,
112
118
  event: 'presence',
@@ -213,6 +219,7 @@ let sessionState = {
213
219
  channelName: null,
214
220
  userName: null,
215
221
  userId: null,
222
+ sessionToken: null,
216
223
  connected: false,
217
224
  };
218
225
 
@@ -299,12 +306,14 @@ async function handleToolCall(name, args) {
299
306
  userId = payload.id;
300
307
  } catch {}
301
308
 
309
+ const sessionToken = `mcp-${crypto.randomBytes(16).toString('hex')}`;
302
310
  sessionState = {
303
311
  token: result.token,
304
312
  channelId: result.channelId,
305
313
  channelName: result.channelName,
306
314
  userName: result.userName,
307
315
  userId,
316
+ sessionToken,
308
317
  connected: true,
309
318
  };
310
319
  saveConfig({ token: result.token, userName: result.userName, userId });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-chat-connect",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "MCP server with channels support for connecting Claude Code sessions to MCP Chat -- real-time team messaging for AI-assisted development",
5
5
  "main": "index.js",
6
6
  "bin": {