Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: address PR feedback - use Switch, remove notification, enable tools by default

Devin AId8ac451e9916
diff --git a/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-service.ts b/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-service.ts
index 3b3f331c52..8a181fb46e 100644
--- a/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-service.ts
+++ b/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-service.ts
@@ -730,6 +730,10 @@ export const aiMcpEndpointServiceFactory = ({
// Update server connections if provided
if (serverIds !== undefined) {
+ // Get existing server connections to identify newly added servers
+ const existingConnections = await aiMcpEndpointServerDAL.find({ aiMcpEndpointId: endpointId });
+ const existingServerIds = new Set(existingConnections.map((conn) => conn.aiMcpServerId));
+
// Validate that all serverIds belong to the same project
if (serverIds.length > 0) {
const servers = await aiMcpServerDAL.find({ $in: { id: serverIds } });
@@ -757,6 +761,23 @@ export const aiMcpEndpointServiceFactory = ({
aiMcpServerId: serverId
}))
);
+
+ // Enable all tools by default for newly added servers
+ const newServerIds = serverIds.filter((id) => !existingServerIds.has(id));
+ if (newServerIds.length > 0) {
+ // Get all tools for the newly added servers
+ const newServerTools = await aiMcpServerToolDAL.find({ $in: { aiMcpServerId: newServerIds } });
+
+ // Enable all tools for the new servers
+ if (newServerTools.length > 0) {
+ await aiMcpEndpointServerToolDAL.insertMany(
+ newServerTools.map((tool) => ({
+ aiMcpEndpointId: endpointId,
+ aiMcpServerToolId: tool.id
+ }))
+ );
+ }
+ }
}
}
diff --git a/frontend/src/pages/ai/MCPEndpointDetailPage/components/MCPEndpointToolSelectionSection.tsx b/frontend/src/pages/ai/MCPEndpointDetailPage/components/MCPEndpointToolSelectionSection.tsx
index 2a25620586..6c9ef0d6c7 100644
--- a/frontend/src/pages/ai/MCPEndpointDetailPage/components/MCPEndpointToolSelectionSection.tsx
+++ b/frontend/src/pages/ai/MCPEndpointDetailPage/components/MCPEndpointToolSelectionSection.tsx
@@ -9,7 +9,7 @@ import {
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { createNotification } from "@app/components/notifications";
-import { Checkbox, Input, Switch, Tooltip } from "@app/components/v2";
+import { Input, Switch, Tooltip } from "@app/components/v2";
import {
ProjectPermissionMcpEndpointActions,
ProjectPermissionSub,
@@ -77,12 +77,10 @@ const ServerToolsSection = ({
const enabledCount = tools.filter((tool) => enabledToolIds.has(tool.id)).length;
const totalCount = tools.length;
- // Count enabled filtered tools for the select all checkbox
+ // Count enabled filtered tools for the toggle all switch
const enabledFilteredCount = filteredTools.filter((tool) => enabledToolIds.has(tool.id)).length;
const allFilteredEnabled =
filteredTools.length > 0 && enabledFilteredCount === filteredTools.length;
- const someFilteredEnabled =
- enabledFilteredCount > 0 && enabledFilteredCount < filteredTools.length;
// Check if tool is enabled
const isToolEnabled = (toolId: string) => {
@@ -128,22 +126,24 @@ const ServerToolsSection = ({
{isExpanded && filteredTools.length > 0 && (
<div className="border-t border-mineshaft-600">
+ <div className="flex items-center justify-between border-b border-mineshaft-600 px-4 py-2">
+ <span className="text-sm text-bunker-300">
+ {allFilteredEnabled ? "Disable" : "Enable"} all tools
+ </span>
+ <Tooltip content={allFilteredEnabled ? "Disable all tools" : "Enable all tools"}>
+ <div>
+ <Switch
+ id={`toggle-all-${serverId}`}
+ isChecked={allFilteredEnabled}
+ onCheckedChange={handleToggleAll}
+ isDisabled={isUpdating || !canEdit}
+ />
+ </div>
+ </Tooltip>
+ </div>
<div className="grid grid-cols-[1fr_auto] items-center gap-2 border-b border-mineshaft-600 px-4 py-2 text-xs font-medium tracking-wider text-bunker-300 uppercase">
<span>Tool Name</span>
- <div className="flex items-center gap-2">
- <span className="mr-1">Enabled</span>
- <Tooltip content={allFilteredEnabled ? "Deselect all tools" : "Select all tools"}>
- <div>
- <Checkbox
- id={`select-all-${serverId}`}
- isChecked={allFilteredEnabled}
- isIndeterminate={someFilteredEnabled}
- onCheckedChange={handleToggleAll}
- isDisabled={isUpdating || !canEdit}
- />
- </div>
- </Tooltip>
- </div>
+ <span>Enabled</span>
</div>
<div className="divide-y divide-mineshaft-600">
{filteredTools.map((tool) => (
@@ -223,10 +223,6 @@ export const MCPEndpointToolSelectionSection = ({ endpointId, projectId, serverI
isEnabled: enableAll
}))
});
- createNotification({
- text: enableAll ? "All tools enabled" : "All tools disabled",
- type: "success"
- });
} catch (error) {
console.error("Failed to update tools:", error);
createNotification({