fix: show MCP tools in all provider groups when shared

When multiple MCP servers expose the same tool names (e.g., several
kusto-mcp instances), each server's group now shows its tools instead
of only the first server getting the tools and others showing 0/0.

Deduplicate the effectiveAutoApprovedCount to avoid double-counting
shared tools in the pill header.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-28 19:35:56 +01:00
co-authored by Copilot
parent 6505493735
commit f0114058ba
3 changed files with 26 additions and 6 deletions
+6 -4
View File
@@ -131,15 +131,17 @@ export function ChatPane({
);
const effectiveAutoApprovedCount = useMemo(() => {
const groups = groupApprovalToolsByProvider(approvalTools, toolingSettings);
let count = 0;
const counted = new Set<string>();
for (const group of groups) {
if (group.serverApprovalKey && effectiveAutoApproved.has(group.serverApprovalKey)) {
count += group.tools.length;
for (const tool of group.tools) counted.add(tool.id);
} else {
count += group.tools.filter((t) => effectiveAutoApproved.has(t.id)).length;
for (const tool of group.tools) {
if (effectiveAutoApproved.has(tool.id)) counted.add(tool.id);
}
}
}
return count;
return counted.size;
}, [approvalTools, effectiveAutoApproved, toolingSettings]);
useEffect(() => {
+16
View File
@@ -306,6 +306,22 @@ export function groupApprovalToolsByProvider(
const groups = new Map<string, ApprovalToolGroup>();
for (const tool of tools) {
// Place MCP tools in every provider group they belong to, so each server
// shows its own tools even when multiple servers share the same tool names.
if (tool.kind === 'mcp' && tool.providerIds.length > 1) {
for (const providerId of tool.providerIds) {
const groupId = `mcp:${providerId}`;
let group = groups.get(groupId);
if (!group) {
const label = serverNames.get(providerId) ?? providerId;
group = { id: groupId, label, kind: 'mcp', tools: [] };
groups.set(groupId, group);
}
group.tools.push(tool);
}
continue;
}
const groupKey = resolveApprovalToolGroupKey(tool, serverNames, profileNames);
let group = groups.get(groupKey.id);
if (!group) {