Skip to content

Commit 15e2b41

Browse files
waleedlatif1claude
andcommitted
feat(canvas): expand MCP tool params into per-row labels on block tile
The MCP Tool block on the workflow canvas previously crammed every selected- tool parameter into a stringified blob under the `Tool` row. Now, when a tool is selected, the tile reads the cached `_toolSchema` and emits one labeled SubBlockRow per parameter (matching the Exa block's per-param layout). Labels reuse `formatParameterLabel` for parity with the editor panel; values pass through the existing `getDisplayValue` so booleans/numbers/arrays render identically to other blocks. Deterministic tile height counts expanded rows so the tile sizes correctly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent b7c937d commit 15e2b41

1 file changed

Lines changed: 48 additions & 6 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { useVariablesStore } from '@/stores/variables/store'
5656
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
5757
import { useWorkflowStore } from '@/stores/workflows/workflow/store'
5858
import { wouldCreateCycle } from '@/stores/workflows/workflow/utils'
59+
import { formatParameterLabel } from '@/tools/params'
5960

6061
const logger = createLogger('WorkflowBlock')
6162

@@ -1136,6 +1137,28 @@ export const WorkflowBlock = memo(function WorkflowBlock({
11361137
return getRouterRows(id, topologySubBlocks.routes?.value)
11371138
}, [type, topologySubBlocks, id])
11381139

1140+
/**
1141+
* Total rendered row count. `mcp-dynamic-args` expands one row per parameter
1142+
* in the cached tool schema, so we count those properties instead of 1.
1143+
*/
1144+
const totalRenderedRowCount = useMemo(() => {
1145+
let count = 0
1146+
for (const row of subBlockRows) {
1147+
for (const subBlock of row) {
1148+
if (subBlock.type === 'mcp-dynamic-args') {
1149+
const schema = subBlockState._toolSchema?.value as
1150+
| { properties?: Record<string, unknown> }
1151+
| undefined
1152+
const properties = schema?.properties
1153+
count += properties && typeof properties === 'object' ? Object.keys(properties).length : 0
1154+
} else {
1155+
count += 1
1156+
}
1157+
}
1158+
}
1159+
return count
1160+
}, [subBlockRows, subBlockState])
1161+
11391162
/**
11401163
* Compute and publish deterministic layout metrics for workflow blocks.
11411164
* This avoids ResizeObserver/animation-frame jitter and prevents initial "jump".
@@ -1147,7 +1170,7 @@ export const WorkflowBlock = memo(function WorkflowBlock({
11471170
blockType: type,
11481171
category: config.category,
11491172
displayTriggerMode,
1150-
visibleSubBlockCount: subBlockRows.reduce((acc, row) => acc + row.length, 0),
1173+
visibleSubBlockCount: totalRenderedRowCount,
11511174
conditionRowCount: conditionRows.length,
11521175
routerRowCount: routerRows.length,
11531176
})
@@ -1156,7 +1179,7 @@ export const WorkflowBlock = memo(function WorkflowBlock({
11561179
type,
11571180
config.category,
11581181
displayTriggerMode,
1159-
subBlockRows.reduce((acc, row) => acc + row.length, 0),
1182+
totalRenderedRowCount,
11601183
conditionRows.length,
11611184
routerRows.length,
11621185
horizontalHandles,
@@ -1378,9 +1401,28 @@ export const WorkflowBlock = memo(function WorkflowBlock({
13781401
</>
13791402
) : (
13801403
subBlockRows.map((row, rowIndex) =>
1381-
row.map((subBlock) => {
1404+
row.flatMap((subBlock) => {
13821405
const rawValue = subBlockState[subBlock.id]?.value
1383-
return (
1406+
if (subBlock.type === 'mcp-dynamic-args') {
1407+
const schema = subBlockState._toolSchema?.value as
1408+
| { properties?: Record<string, unknown> }
1409+
| undefined
1410+
const properties = schema?.properties
1411+
if (properties && typeof properties === 'object') {
1412+
const args = (
1413+
rawValue && typeof rawValue === 'object' ? rawValue : {}
1414+
) as Record<string, unknown>
1415+
return Object.keys(properties).map((paramName) => (
1416+
<SubBlockRow
1417+
key={`${subBlock.id}-${paramName}-${rowIndex}`}
1418+
title={formatParameterLabel(paramName)}
1419+
value={getDisplayValue(args[paramName])}
1420+
/>
1421+
))
1422+
}
1423+
return []
1424+
}
1425+
return [
13841426
<SubBlockRow
13851427
key={`${subBlock.id}-${rowIndex}`}
13861428
title={subBlock.title ?? subBlock.id}
@@ -1394,8 +1436,8 @@ export const WorkflowBlock = memo(function WorkflowBlock({
13941436
displayAdvancedOptions={effectiveAdvanced}
13951437
canonicalIndex={canonicalIndex}
13961438
canonicalModeOverrides={canonicalModeOverrides}
1397-
/>
1398-
)
1439+
/>,
1440+
]
13991441
})
14001442
)
14011443
)}

0 commit comments

Comments
 (0)