@yeaft/webchat-agent 0.1.38 → 0.1.40
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/claude.js +16 -8
- package/conversation.js +2 -2
- package/package.json +1 -1
package/claude.js
CHANGED
|
@@ -280,19 +280,20 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
// 从 tools 列表提取 MCP servers,发送 per-conversation MCP 列表
|
|
283
|
-
const mcpServers = extractMcpServers(state.tools);
|
|
283
|
+
const { serverNames: mcpServers, serverTools: mcpServerTools } = extractMcpServers(state.tools);
|
|
284
284
|
if (mcpServers.length > 0) {
|
|
285
285
|
// 根据当前 disallowed 设置计算每个 server 的 enabled 状态
|
|
286
286
|
const effectiveDisallowed = state.disallowedTools ?? ctx.CONFIG.disallowedTools ?? [];
|
|
287
287
|
const serversWithState = mcpServers.map(name => ({
|
|
288
288
|
name,
|
|
289
|
-
enabled: !effectiveDisallowed.some(d => d === `mcp__${name}`),
|
|
289
|
+
enabled: !effectiveDisallowed.some(d => d === `mcp__${name}` || d.startsWith(`mcp__${name}__`)),
|
|
290
290
|
source: name === 'playwright' ? 'Built-in' : 'MCP'
|
|
291
291
|
}));
|
|
292
292
|
ctx.sendToServer({
|
|
293
293
|
type: 'conversation_mcp_update',
|
|
294
294
|
conversationId,
|
|
295
|
-
servers: serversWithState
|
|
295
|
+
servers: serversWithState,
|
|
296
|
+
serverTools: mcpServerTools
|
|
296
297
|
});
|
|
297
298
|
}
|
|
298
299
|
}
|
|
@@ -478,19 +479,26 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
|
|
|
478
479
|
}
|
|
479
480
|
|
|
480
481
|
/**
|
|
481
|
-
* 从 tools 列表中提取 MCP server
|
|
482
|
+
* 从 tools 列表中提取 MCP server 名称和 per-server tools 映射。
|
|
482
483
|
* MCP 工具名称格式: mcp__<serverName>__<toolName>
|
|
483
484
|
* @param {string[]} tools
|
|
484
|
-
* @returns {string[]
|
|
485
|
+
* @returns {{ serverNames: string[], serverTools: Object<string, string[]> }}
|
|
485
486
|
*/
|
|
486
487
|
function extractMcpServers(tools) {
|
|
487
|
-
const
|
|
488
|
+
const serverToolsMap = {};
|
|
488
489
|
for (const tool of tools) {
|
|
489
490
|
const parts = tool.split('__');
|
|
490
491
|
if (parts.length >= 3 && parts[0] === 'mcp') {
|
|
491
|
-
|
|
492
|
+
const serverName = parts[1];
|
|
493
|
+
if (!serverToolsMap[serverName]) {
|
|
494
|
+
serverToolsMap[serverName] = [];
|
|
495
|
+
}
|
|
496
|
+
serverToolsMap[serverName].push(tool);
|
|
492
497
|
}
|
|
493
498
|
}
|
|
494
|
-
return
|
|
499
|
+
return {
|
|
500
|
+
serverNames: Object.keys(serverToolsMap),
|
|
501
|
+
serverTools: serverToolsMap
|
|
502
|
+
};
|
|
495
503
|
}
|
|
496
504
|
|
package/conversation.js
CHANGED
|
@@ -151,7 +151,7 @@ export async function createConversation(msg) {
|
|
|
151
151
|
const effectiveDisallowed = disallowedTools || ctx.CONFIG.disallowedTools || [];
|
|
152
152
|
const serversWithState = ctx.mcpServers.map(s => ({
|
|
153
153
|
name: s.name,
|
|
154
|
-
enabled: !effectiveDisallowed.some(d => d === `mcp__${s.name}`),
|
|
154
|
+
enabled: !effectiveDisallowed.some(d => d === `mcp__${s.name}` || d.startsWith(`mcp__${s.name}__`)),
|
|
155
155
|
source: s.source
|
|
156
156
|
}));
|
|
157
157
|
ctx.sendToServer({
|
|
@@ -230,7 +230,7 @@ export async function resumeConversation(msg) {
|
|
|
230
230
|
const effectiveDisallowed = disallowedTools || ctx.CONFIG.disallowedTools || [];
|
|
231
231
|
const serversWithState = ctx.mcpServers.map(s => ({
|
|
232
232
|
name: s.name,
|
|
233
|
-
enabled: !effectiveDisallowed.some(d => d === `mcp__${s.name}`),
|
|
233
|
+
enabled: !effectiveDisallowed.some(d => d === `mcp__${s.name}` || d.startsWith(`mcp__${s.name}__`)),
|
|
234
234
|
source: s.source
|
|
235
235
|
}));
|
|
236
236
|
ctx.sendToServer({
|