Skip to content

Commit b70bdb4

Browse files
committed
fix(tool-input): handle mcp-server type in refresh, validation, badges, and usage control
1 parent d022a55 commit b70bdb4

File tree

1 file changed

+33
-15
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input

1 file changed

+33
-15
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ export const ToolInput = memo(function ToolInput({
524524
)
525525
const hasRefreshedRef = useRef(false)
526526

527-
const hasMcpTools = selectedTools.some((tool) => tool.type === 'mcp')
527+
const hasMcpTools = selectedTools.some((tool) => tool.type === 'mcp' || tool.type === 'mcp-server')
528528

529529
useEffect(() => {
530530
if (isPreview) return
@@ -541,9 +541,36 @@ export const ToolInput = memo(function ToolInput({
541541
*/
542542
const getMcpToolIssue = useCallback(
543543
(tool: StoredTool) => {
544-
if (tool.type !== 'mcp') return null
544+
if (tool.type !== 'mcp' && tool.type !== 'mcp-server') return null
545545

546546
const serverId = tool.params?.serverId as string
547+
const serverStates = mcpServers.map((s) => ({
548+
id: s.id,
549+
url: s.url,
550+
connectionStatus: s.connectionStatus,
551+
lastError: s.lastError ?? undefined,
552+
}))
553+
const discoveredTools = mcpTools.map((t) => ({
554+
serverId: t.serverId,
555+
name: t.name,
556+
inputSchema: t.inputSchema,
557+
}))
558+
559+
if (tool.type === 'mcp-server') {
560+
// Server-level validation: only check server connectivity
561+
return validateMcpTool(
562+
{
563+
serverId,
564+
serverUrl: tool.params?.serverUrl as string | undefined,
565+
toolName: '__server_check__',
566+
schema: undefined,
567+
},
568+
serverStates,
569+
// Pass a fake discovered tool so tool_not_found doesn't trigger
570+
[...discoveredTools, { serverId, name: '__server_check__', inputSchema: undefined }]
571+
)
572+
}
573+
547574
const toolName = tool.params?.toolName as string
548575

549576
// Try to get fresh schema from DB (enables real-time updates after MCP refresh)
@@ -563,17 +590,8 @@ export const ToolInput = memo(function ToolInput({
563590
toolName,
564591
schema,
565592
},
566-
mcpServers.map((s) => ({
567-
id: s.id,
568-
url: s.url,
569-
connectionStatus: s.connectionStatus,
570-
lastError: s.lastError ?? undefined,
571-
})),
572-
mcpTools.map((t) => ({
573-
serverId: t.serverId,
574-
name: t.name,
575-
inputSchema: t.inputSchema,
576-
}))
593+
serverStates,
594+
discoveredTools
577595
)
578596
},
579597
[mcpTools, mcpServers, storedMcpTools, workflowId]
@@ -1738,7 +1756,7 @@ export const ToolInput = memo(function ToolInput({
17381756
{tool.params?.toolCount || mcpServerTools.length} tools
17391757
</Badge>
17401758
)}
1741-
{isMcpTool &&
1759+
{(isMcpTool || isMcpServer) &&
17421760
!mcpDataLoading &&
17431761
(() => {
17441762
const issue = getMcpToolIssue(tool)
@@ -1773,7 +1791,7 @@ export const ToolInput = memo(function ToolInput({
17731791
)}
17741792
</div>
17751793
<div className='flex flex-shrink-0 items-center gap-[8px]'>
1776-
{supportsToolControl && !(isMcpTool && isMcpToolUnavailable(tool)) && (
1794+
{supportsToolControl && !((isMcpTool || isMcpServer) && isMcpToolUnavailable(tool)) && (
17771795
<Popover
17781796
open={usageControlPopoverIndex === toolIndex}
17791797
onOpenChange={(open) => setUsageControlPopoverIndex(open ? toolIndex : null)}

0 commit comments

Comments
 (0)