@yeaft/webchat-agent 0.1.35 → 0.1.36

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/claude.js +34 -0
  2. package/package.json +1 -1
package/claude.js CHANGED
@@ -277,6 +277,23 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
277
277
  });
278
278
  }
279
279
  }
280
+
281
+ // 从 tools 列表提取 MCP servers,发送 per-conversation MCP 列表
282
+ const mcpServers = extractMcpServers(state.tools);
283
+ if (mcpServers.length > 0) {
284
+ // 根据当前 disallowed 设置计算每个 server 的 enabled 状态
285
+ const effectiveDisallowed = state.disallowedTools ?? ctx.CONFIG.disallowedTools ?? [];
286
+ const serversWithState = mcpServers.map(name => ({
287
+ name,
288
+ enabled: !effectiveDisallowed.some(d => d === `mcp__${name}`),
289
+ source: name === 'playwright' ? 'Built-in' : 'MCP'
290
+ }));
291
+ ctx.sendToServer({
292
+ type: 'conversation_mcp_update',
293
+ conversationId,
294
+ servers: serversWithState
295
+ });
296
+ }
280
297
  }
281
298
 
282
299
  // 捕获 compact 相关的 system 消息
@@ -459,3 +476,20 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
459
476
  }
460
477
  }
461
478
 
479
+ /**
480
+ * 从 tools 列表中提取 MCP server 名称。
481
+ * MCP 工具名称格式: mcp__<serverName>__<toolName>
482
+ * @param {string[]} tools
483
+ * @returns {string[]} 去重后的 server 名称列表
484
+ */
485
+ function extractMcpServers(tools) {
486
+ const serverNames = new Set();
487
+ for (const tool of tools) {
488
+ const parts = tool.split('__');
489
+ if (parts.length >= 3 && parts[0] === 'mcp') {
490
+ serverNames.add(parts[1]);
491
+ }
492
+ }
493
+ return [...serverNames];
494
+ }
495
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",