Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added back useMcpToolsEvents for event-driven discovery
  • Loading branch information
waleedlatif1 committed Feb 10, 2026
commit 35f3f316769677ff3e9b3b5d57d08d4c9677887c
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ export function McpDeploy({

const currentIds = new Set(selectedServerIds)
const nextIds = new Set(selectedServerIdsForForm)
const toAdd = selectedServerIdsForForm.filter((id) => !currentIds.has(id))
const toAdd = new Set(selectedServerIdsForForm.filter((id) => !currentIds.has(id)))
const toRemove = selectedServerIds.filter((id) => !nextIds.has(id))
const shouldUpdateExisting = hasToolConfigurationChanges

if (toAdd.length === 0 && toRemove.length === 0 && !shouldUpdateExisting) return
if (toAdd.size === 0 && toRemove.length === 0 && !shouldUpdateExisting) return

onSubmittingChange?.(true)
try {
Expand All @@ -302,6 +302,8 @@ export function McpDeploy({
nextServerToolsMap[serverId] = { tool: addedTool, isLoading: false }
onAddedToServer?.()
logger.info(`Added workflow ${workflowId} as tool to server ${serverId}`)
} catch (error) {
logger.error(`Failed to add tool to server ${serverId}:`, error)
} finally {
setPendingServerChanges((prev) => {
const next = new Set(prev)
Expand All @@ -323,6 +325,8 @@ export function McpDeploy({
toolId: toolInfo.tool.id,
})
delete nextServerToolsMap[serverId]
} catch (error) {
logger.error(`Failed to remove tool from server ${serverId}:`, error)
} finally {
setPendingServerChanges((prev) => {
const next = new Set(prev)
Expand All @@ -334,23 +338,27 @@ export function McpDeploy({

if (shouldUpdateExisting) {
for (const serverId of selectedServerIdsForForm) {
if (toAdd.has(serverId)) continue
const toolInfo = nextServerToolsMap[serverId]
if (!toolInfo?.tool) continue

await updateToolMutation.mutateAsync({
workspaceId,
serverId,
toolId: toolInfo.tool.id,
toolName: toolName.trim(),
toolDescription: toolDescription.trim() || undefined,
parameterSchema,
})
try {
await updateToolMutation.mutateAsync({
workspaceId,
serverId,
toolId: toolInfo.tool.id,
toolName: toolName.trim(),
toolDescription: toolDescription.trim() || undefined,
parameterSchema,
})
} catch (error) {
logger.error(`Failed to update tool on server ${serverId}:`, error)
}
}
}
Comment thread
waleedlatif1 marked this conversation as resolved.

setServerToolsMap(nextServerToolsMap)
Comment thread
waleedlatif1 marked this conversation as resolved.
Outdated
setDraftSelectedServerIds(null)
// Update saved values after successful save (triggers re-render → hasChanges becomes false)
setSavedValues({
toolName,
toolDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ import {
type CustomTool as CustomToolDefinition,
useCustomTools,
} from '@/hooks/queries/custom-tools'
import { useForceRefreshMcpTools, useMcpServers, useStoredMcpTools } from '@/hooks/queries/mcp'
import {
useForceRefreshMcpTools,
useMcpServers,
useMcpToolsEvents,
useStoredMcpTools,
} from '@/hooks/queries/mcp'
import {
useChildDeploymentStatus,
useDeployChildWorkflow,
Expand Down Expand Up @@ -1035,6 +1040,7 @@ export const ToolInput = memo(function ToolInput({
const { data: mcpServers = [], isLoading: mcpServersLoading } = useMcpServers(workspaceId)
const { data: storedMcpTools = [] } = useStoredMcpTools(workspaceId)
const forceRefreshMcpTools = useForceRefreshMcpTools()
useMcpToolsEvents(workspaceId)
const openSettingsModal = useSettingsModalStore((state) => state.openModal)
const mcpDataLoading = mcpLoading || mcpServersLoading

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ interface McpServer {
transport?: string
url?: string
headers?: Record<string, string>
enabled?: boolean
connectionStatus?: 'connected' | 'disconnected' | 'error'
lastError?: string | null
lastConnected?: string
Expand Down Expand Up @@ -416,7 +417,6 @@ export function MCP({ initialServerId }: MCPProps) {
const [urlScrollLeft, setUrlScrollLeft] = useState(0)
const [headerScrollLeft, setHeaderScrollLeft] = useState<Record<string, number>>({})

// Edit modal state
const [showEditModal, setShowEditModal] = useState(false)
const [editFormData, setEditFormData] = useState<McpServerFormData>(DEFAULT_FORM_DATA)
const [editOriginalData, setEditOriginalData] = useState<McpServerFormData>(DEFAULT_FORM_DATA)
Expand Down Expand Up @@ -952,6 +952,7 @@ export function MCP({ initialServerId }: MCPProps) {
return
}
Comment thread
waleedlatif1 marked this conversation as resolved.

const currentServer = servers.find((s) => s.id === selectedServerId)
await updateServerMutation.mutateAsync({
workspaceId,
serverId: selectedServerId,
Expand All @@ -961,7 +962,7 @@ export function MCP({ initialServerId }: MCPProps) {
url: editFormData.url,
headers: headersRecord,
timeout: editFormData.timeout || 30000,
enabled: true,
enabled: currentServer?.enabled ?? true,
},
})

Expand All @@ -979,6 +980,7 @@ export function MCP({ initialServerId }: MCPProps) {
updateServerMutation,
workspaceId,
headersToRecord,
servers,
])

/**
Expand Down
2 changes: 0 additions & 2 deletions apps/sim/tools/jira/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,6 @@ export const SUCCESS_OUTPUT: OutputProperty = {
description: 'Operation success status',
}

// --- Parameter interfaces ---

export interface JiraRetrieveParams {
accessToken: string
issueKey: string
Expand Down
22 changes: 16 additions & 6 deletions apps/sim/tools/jira/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { createLogger } from '@sim/logger'

const logger = createLogger('JiraUtils')

const MAX_ATTACHMENT_SIZE = 50 * 1024 * 1024

/**
* Extracts plain text from Atlassian Document Format (ADF) content.
* Returns null if content is falsy.
Expand Down Expand Up @@ -56,6 +62,10 @@ export async function downloadJiraAttachments(

for (const att of attachments) {
if (!att.content) continue
if (att.size > MAX_ATTACHMENT_SIZE) {
logger.warn(`Skipping attachment ${att.filename} (${att.size} bytes): exceeds size limit`)
continue
}
try {
const response = await fetch(att.content, {
headers: {
Expand All @@ -64,7 +74,10 @@ export async function downloadJiraAttachments(
},
})

if (!response.ok) continue
if (!response.ok) {
logger.warn(`Failed to download attachment ${att.filename}: HTTP ${response.status}`)
continue
}

const arrayBuffer = await response.arrayBuffer()
const buffer = Buffer.from(arrayBuffer)
Expand All @@ -75,8 +88,8 @@ export async function downloadJiraAttachments(
data: buffer.toString('base64'),
size: buffer.length,
})
} catch {
// Skip failed downloads
} catch (error) {
logger.warn(`Failed to download attachment ${att.filename}:`, error)
}
}

Expand All @@ -94,7 +107,6 @@ export async function getJiraCloudId(domain: string, accessToken: string): Promi

const resources = await response.json()

// If we have resources, find the matching one
if (Array.isArray(resources) && resources.length > 0) {
const normalizedInput = `https://${domain}`.toLowerCase()
const matchedResource = resources.find((r) => r.url.toLowerCase() === normalizedInput)
Expand All @@ -104,8 +116,6 @@ export async function getJiraCloudId(domain: string, accessToken: string): Promi
}
}

// If we couldn't find a match, return the first resource's ID
// This is a fallback in case the URL matching fails
if (Array.isArray(resources) && resources.length > 0) {
return resources[0].id
}
Expand Down