mcp-chat-connect 1.2.0 → 1.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/index.js +73 -3
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -249,6 +249,7 @@ let sessionState = {
|
|
|
249
249
|
userName: null,
|
|
250
250
|
userId: null,
|
|
251
251
|
sessionToken: null,
|
|
252
|
+
sessionLabel: null,
|
|
252
253
|
connected: false,
|
|
253
254
|
};
|
|
254
255
|
|
|
@@ -316,6 +317,17 @@ function getTools() {
|
|
|
316
317
|
description: 'Check your current MCP Chat connection status.',
|
|
317
318
|
inputSchema: { type: 'object', properties: {} },
|
|
318
319
|
},
|
|
320
|
+
{
|
|
321
|
+
name: 'mcp_chat_join',
|
|
322
|
+
description: 'Connect to a specific MCP Chat channel by ID without opening a browser. Requires prior authentication (saved token from a previous mcp_chat_connect). Used by agents to join channels created by the parent session.',
|
|
323
|
+
inputSchema: {
|
|
324
|
+
type: 'object',
|
|
325
|
+
properties: {
|
|
326
|
+
channel_id: { type: 'number', description: 'Channel ID to join' },
|
|
327
|
+
},
|
|
328
|
+
required: ['channel_id'],
|
|
329
|
+
},
|
|
330
|
+
},
|
|
319
331
|
{
|
|
320
332
|
name: 'mcp_chat_create_channel',
|
|
321
333
|
description: 'Create a new MCP Chat channel. You become the admin.',
|
|
@@ -380,16 +392,28 @@ async function handleToolCall(name, args) {
|
|
|
380
392
|
userName: result.userName,
|
|
381
393
|
userId,
|
|
382
394
|
sessionToken,
|
|
395
|
+
sessionLabel: null,
|
|
383
396
|
connected: true,
|
|
384
397
|
};
|
|
385
398
|
saveConfig({ token: result.token, userName: result.userName, userId });
|
|
386
399
|
|
|
400
|
+
// Register session to get sequential label
|
|
401
|
+
let sessionLabel = 'Session';
|
|
402
|
+
try {
|
|
403
|
+
const regResult = await apiCall('register_session', {
|
|
404
|
+
channel_id: result.channelId,
|
|
405
|
+
session_token: sessionToken,
|
|
406
|
+
}, result.token);
|
|
407
|
+
sessionLabel = regResult.label || 'Session';
|
|
408
|
+
sessionState.sessionLabel = sessionLabel;
|
|
409
|
+
} catch {}
|
|
410
|
+
|
|
387
411
|
// Start WebSocket listener for real-time push
|
|
388
412
|
connectWebSocket();
|
|
389
413
|
|
|
390
414
|
// Check for package updates
|
|
391
415
|
const updateNotice = await checkForUpdate();
|
|
392
|
-
let responseText = `Connected to #${result.channelName} as ${result.userName}. Live messages will now be pushed into this session. You can also use mcp_chat_send to send messages and mcp_chat_read to fetch history.`;
|
|
416
|
+
let responseText = `Connected to #${result.channelName} as ${result.userName} (${sessionLabel}). Live messages will now be pushed into this session. You can also use mcp_chat_send to send messages and mcp_chat_read to fetch history.`;
|
|
393
417
|
if (updateNotice) {
|
|
394
418
|
responseText += `\n\n${updateNotice}`;
|
|
395
419
|
}
|
|
@@ -400,6 +424,52 @@ async function handleToolCall(name, args) {
|
|
|
400
424
|
}
|
|
401
425
|
}
|
|
402
426
|
|
|
427
|
+
case 'mcp_chat_join': {
|
|
428
|
+
if (!sessionState.token) {
|
|
429
|
+
return { content: [{ type: 'text', text: 'Not authenticated. A user must run mcp_chat_connect first to save credentials.' }], isError: true };
|
|
430
|
+
}
|
|
431
|
+
const channelId = parseInt(args.channel_id, 10);
|
|
432
|
+
if (!channelId || isNaN(channelId)) {
|
|
433
|
+
return { content: [{ type: 'text', text: 'Valid channel_id is required.' }], isError: true };
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// Verify we can access this channel
|
|
437
|
+
try {
|
|
438
|
+
const channelsResult = await apiCall('list_channels', {}, sessionState.token);
|
|
439
|
+
const channel = channelsResult.channels?.find(c => c.id === channelId);
|
|
440
|
+
if (!channel) {
|
|
441
|
+
return { content: [{ type: 'text', text: `Channel ${channelId} not found or you are not a member.` }], isError: true };
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
disconnectWebSocket();
|
|
445
|
+
const sessionToken = `mcp-${crypto.randomBytes(16).toString('hex')}`;
|
|
446
|
+
sessionState = {
|
|
447
|
+
...sessionState,
|
|
448
|
+
channelId,
|
|
449
|
+
channelName: channel.name,
|
|
450
|
+
sessionToken,
|
|
451
|
+
sessionLabel: null,
|
|
452
|
+
connected: true,
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// Register session to get sequential label
|
|
456
|
+
let sessionLabel = 'Session';
|
|
457
|
+
try {
|
|
458
|
+
const regResult = await apiCall('register_session', {
|
|
459
|
+
channel_id: channelId,
|
|
460
|
+
session_token: sessionToken,
|
|
461
|
+
}, sessionState.token);
|
|
462
|
+
sessionLabel = regResult.label || 'Session';
|
|
463
|
+
sessionState.sessionLabel = sessionLabel;
|
|
464
|
+
} catch {}
|
|
465
|
+
|
|
466
|
+
connectWebSocket();
|
|
467
|
+
return { content: [{ type: 'text', text: `Joined #${channel.name} (ID: ${channelId}) as ${sessionState.userName} (${sessionLabel}). Live messages are now being pushed.` }] };
|
|
468
|
+
} catch (err) {
|
|
469
|
+
return { content: [{ type: 'text', text: `Failed to join channel: ${err.message}` }], isError: true };
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
403
473
|
case 'mcp_chat_send': {
|
|
404
474
|
if (!sessionState.connected) {
|
|
405
475
|
return { content: [{ type: 'text', text: 'Not connected. Run mcp_chat_connect first.' }], isError: true };
|
|
@@ -466,10 +536,10 @@ async function handleToolCall(name, args) {
|
|
|
466
536
|
|
|
467
537
|
case 'mcp_chat_status': {
|
|
468
538
|
if (!sessionState.connected) {
|
|
469
|
-
return { content: [{ type: 'text', text: sessionState.token ? 'Authenticated but not connected to a channel. Run mcp_chat_connect to pick a channel.' : 'Not connected. Run mcp_chat_connect to authenticate and select a channel.' }] };
|
|
539
|
+
return { content: [{ type: 'text', text: sessionState.token ? 'Authenticated but not connected to a channel. Run mcp_chat_connect or mcp_chat_join to pick a channel.' : 'Not connected. Run mcp_chat_connect to authenticate and select a channel.' }] };
|
|
470
540
|
}
|
|
471
541
|
const wsStatus = wsConnection?.readyState === 1 ? 'live (receiving messages)' : 'reconnecting...';
|
|
472
|
-
return { content: [{ type: 'text', text: `Connected to #${sessionState.channelName} as ${sessionState.userName}\nWebSocket: ${wsStatus}` }] };
|
|
542
|
+
return { content: [{ type: 'text', text: `Connected to #${sessionState.channelName} as ${sessionState.userName} (${sessionState.sessionLabel || 'Session'})\nWebSocket: ${wsStatus}` }] };
|
|
473
543
|
}
|
|
474
544
|
|
|
475
545
|
case 'mcp_chat_create_channel': {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-chat-connect",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.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": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"development",
|
|
17
17
|
"collaboration"
|
|
18
18
|
],
|
|
19
|
-
"author": "
|
|
19
|
+
"author": "mncoleman",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|