From 6791d968b8ae0d03ced3c00524a38c006c716de6 Mon Sep 17 00:00:00 2001 From: Waleed Date: Wed, 10 Dec 2025 11:57:18 -0800 Subject: [PATCH] fix(mcp): added backfill effect to add missing descriptions for mcp tools (#2290) --- .../tool-input/components/mcp-tools-list.tsx | 6 +++- .../components/tool-input/tool-input.tsx | 30 ++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/mcp-tools-list.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/mcp-tools-list.tsx index 2c2e51f43..d3ffbe78e 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/mcp-tools-list.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/mcp-tools-list.tsx @@ -10,6 +10,7 @@ const IconComponent = ({ icon: Icon, className }: { icon: any; className?: strin interface McpTool { id: string name: string + description?: string serverId: string serverName: string icon: React.ComponentType @@ -76,7 +77,10 @@ export function McpToolsList({ }, isExpanded: true, usageControl: 'auto', - schema: mcpTool.inputSchema, + schema: { + ...mcpTool.inputSchema, + description: mcpTool.description, + }, } onToolSelect(newTool) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx index 4dad09eef..eaeecce09 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx @@ -858,16 +858,22 @@ export function ToolInput({ return } - const mcpToolsNeedingSchema = selectedTools.filter( - (tool) => tool.type === 'mcp' && !tool.schema && tool.params?.toolName + // Find MCP tools that need schema or are missing description + const mcpToolsNeedingUpdate = selectedTools.filter( + (tool) => + tool.type === 'mcp' && tool.params?.toolName && (!tool.schema || !tool.schema.description) ) - if (mcpToolsNeedingSchema.length === 0) { + if (mcpToolsNeedingUpdate.length === 0) { return } const updatedTools = selectedTools.map((tool) => { - if (tool.type !== 'mcp' || tool.schema || !tool.params?.toolName) { + if (tool.type !== 'mcp' || !tool.params?.toolName) { + return tool + } + + if (tool.schema?.description) { return tool } @@ -877,17 +883,27 @@ export function ToolInput({ if (mcpTool?.inputSchema) { logger.info(`Backfilling schema for MCP tool: ${tool.params.toolName}`) - return { ...tool, schema: mcpTool.inputSchema } + return { + ...tool, + schema: { + ...mcpTool.inputSchema, + description: mcpTool.description, + }, + } } return tool }) - const hasChanges = updatedTools.some((tool, i) => tool.schema && !selectedTools[i].schema) + const hasChanges = updatedTools.some( + (tool, i) => + (tool.schema && !selectedTools[i].schema) || + (tool.schema?.description && !selectedTools[i].schema?.description) + ) if (hasChanges) { hasBackfilledRef.current = true - logger.info(`Backfilled schemas for ${mcpToolsNeedingSchema.length} MCP tool(s)`) + logger.info(`Backfilled schemas for ${mcpToolsNeedingUpdate.length} MCP tool(s)`) setStoreValue(updatedTools) } }, [mcpTools, mcpLoading, selectedTools, isPreview, setStoreValue])