Skip to content

Commit 6791d96

Browse files
authored
fix(mcp): added backfill effect to add missing descriptions for mcp tools (#2290)
1 parent 163db5c commit 6791d96

File tree

2 files changed

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

2 files changed

+28
-8
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const IconComponent = ({ icon: Icon, className }: { icon: any; className?: strin
1010
interface McpTool {
1111
id: string
1212
name: string
13+
description?: string
1314
serverId: string
1415
serverName: string
1516
icon: React.ComponentType<any>
@@ -76,7 +77,10 @@ export function McpToolsList({
7677
},
7778
isExpanded: true,
7879
usageControl: 'auto',
79-
schema: mcpTool.inputSchema,
80+
schema: {
81+
...mcpTool.inputSchema,
82+
description: mcpTool.description,
83+
},
8084
}
8185

8286
onToolSelect(newTool)

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -858,16 +858,22 @@ export function ToolInput({
858858
return
859859
}
860860

861-
const mcpToolsNeedingSchema = selectedTools.filter(
862-
(tool) => tool.type === 'mcp' && !tool.schema && tool.params?.toolName
861+
// Find MCP tools that need schema or are missing description
862+
const mcpToolsNeedingUpdate = selectedTools.filter(
863+
(tool) =>
864+
tool.type === 'mcp' && tool.params?.toolName && (!tool.schema || !tool.schema.description)
863865
)
864866

865-
if (mcpToolsNeedingSchema.length === 0) {
867+
if (mcpToolsNeedingUpdate.length === 0) {
866868
return
867869
}
868870

869871
const updatedTools = selectedTools.map((tool) => {
870-
if (tool.type !== 'mcp' || tool.schema || !tool.params?.toolName) {
872+
if (tool.type !== 'mcp' || !tool.params?.toolName) {
873+
return tool
874+
}
875+
876+
if (tool.schema?.description) {
871877
return tool
872878
}
873879

@@ -877,17 +883,27 @@ export function ToolInput({
877883

878884
if (mcpTool?.inputSchema) {
879885
logger.info(`Backfilling schema for MCP tool: ${tool.params.toolName}`)
880-
return { ...tool, schema: mcpTool.inputSchema }
886+
return {
887+
...tool,
888+
schema: {
889+
...mcpTool.inputSchema,
890+
description: mcpTool.description,
891+
},
892+
}
881893
}
882894

883895
return tool
884896
})
885897

886-
const hasChanges = updatedTools.some((tool, i) => tool.schema && !selectedTools[i].schema)
898+
const hasChanges = updatedTools.some(
899+
(tool, i) =>
900+
(tool.schema && !selectedTools[i].schema) ||
901+
(tool.schema?.description && !selectedTools[i].schema?.description)
902+
)
887903

888904
if (hasChanges) {
889905
hasBackfilledRef.current = true
890-
logger.info(`Backfilled schemas for ${mcpToolsNeedingSchema.length} MCP tool(s)`)
906+
logger.info(`Backfilled schemas for ${mcpToolsNeedingUpdate.length} MCP tool(s)`)
891907
setStoreValue(updatedTools)
892908
}
893909
}, [mcpTools, mcpLoading, selectedTools, isPreview, setStoreValue])

0 commit comments

Comments
 (0)