Skip to content

Commit 5458e9d

Browse files
committed
address comments
1 parent 40430df commit 5458e9d

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/mcp/mcp.tsx

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ import {
1414
Textarea,
1515
} from '@/components/emcn'
1616
import { cn } from '@/lib/core/utils/cn'
17-
import { getMeaningfulWorkflowDescription, sanitizeToolName } from '@/lib/mcp/workflow-tool-schema'
17+
import {
18+
extractDescriptionOverrides,
19+
generateToolInputSchema,
20+
getMeaningfulWorkflowDescription,
21+
sanitizeToolName,
22+
} from '@/lib/mcp/workflow-tool-schema'
1823
import { normalizeInputFormatValue } from '@/lib/workflows/input-format'
1924
import { isInputDefinitionTrigger } from '@/lib/workflows/triggers/input-definition-triggers'
2025
import type { InputFormatField } from '@/lib/workflows/types'
@@ -70,7 +75,9 @@ function haveSameOverrides(a: Record<string, string>, b: Record<string, string>)
7075

7176
/**
7277
* Reduce the edited descriptions to the sparse set that actually overrides the Start-block
73-
* defaults: a real, non-empty value that differs from the field's Start-block description.
78+
* defaults: a real value that differs from both the field name and the field's Start-block
79+
* description. Mirrors the server's extractDescriptionOverrides so the deploy-modal and
80+
* Settings/legacy write paths agree on what counts as an override.
7481
*/
7582
function computeDescriptionOverrides(
7683
descriptions: Record<string, string>,
@@ -79,7 +86,7 @@ function computeDescriptionOverrides(
7986
const overrides: Record<string, string> = {}
8087
for (const [name, value] of Object.entries(descriptions)) {
8188
const trimmed = value.trim()
82-
if (trimmed && trimmed !== (startBlockDescriptions[name] ?? '').trim()) {
89+
if (trimmed && trimmed !== name && trimmed !== (startBlockDescriptions[name] ?? '').trim()) {
8390
overrides[name] = trimmed
8491
}
8592
}
@@ -227,7 +234,7 @@ export function McpDeploy({
227234
const [savedValues, setSavedValues] = useState<{
228235
toolName: string
229236
toolDescription: string
230-
overrides: Record<string, string>
237+
descriptions: Record<string, string>
231238
} | null>(null)
232239

233240
useEffect(() => {
@@ -238,32 +245,52 @@ export function McpDeploy({
238245
if (toolInfo?.tool) {
239246
const initialToolName = toolInfo.tool.toolName
240247
const initialToolDescription = toolInfo.tool.toolDescription ?? ''
241-
const initialOverrides = toolInfo.tool.parameterDescriptionOverrides ?? {}
248+
const storedOverrides = toolInfo.tool.parameterDescriptionOverrides ?? {}
249+
// Tools created before the overrides column kept custom descriptions only in the stored
250+
// schema; derive them (dropping field-name and Start-block-default values) so opening and
251+
// saving the form never wipes descriptions that were never migrated to the column.
252+
const initialOverrides =
253+
Object.keys(storedOverrides).length > 0
254+
? storedOverrides
255+
: extractDescriptionOverrides(
256+
toolInfo.tool.parameterSchema,
257+
generateToolInputSchema(inputFormat)
258+
)
242259

243260
setToolName(initialToolName)
244261
setToolDescription(initialToolDescription)
245262
setParameterDescriptions(initialOverrides)
246263
setSavedValues({
247264
toolName: initialToolName,
248265
toolDescription: initialToolDescription,
249-
overrides: computeDescriptionOverrides(initialOverrides, startBlockDescriptions),
266+
descriptions: initialOverrides,
250267
})
251268
break
252269
}
253270
}
254-
}, [servers, serverToolsMap, startBlockDescriptions, savedValues])
271+
}, [servers, serverToolsMap, startBlockDescriptions, inputFormat, savedValues])
255272

256273
const selectedServerIdsForForm = draftSelectedServerIds ?? selectedServerIds
257274

258275
const hasToolConfigurationChanges = useMemo(() => {
259276
if (!savedValues) return false
260277
if (toolName !== savedValues.toolName) return true
261278
if (toolDescription.trim() !== savedValues.toolDescription.trim()) return true
262-
if (!haveSameOverrides(parameterDescriptionOverrides, savedValues.overrides)) {
279+
const savedOverrides = computeDescriptionOverrides(
280+
savedValues.descriptions,
281+
startBlockDescriptions
282+
)
283+
if (!haveSameOverrides(parameterDescriptionOverrides, savedOverrides)) {
263284
return true
264285
}
265286
return false
266-
}, [toolName, toolDescription, parameterDescriptionOverrides, savedValues])
287+
}, [
288+
toolName,
289+
toolDescription,
290+
parameterDescriptionOverrides,
291+
savedValues,
292+
startBlockDescriptions,
293+
])
267294
const hasServerSelectionChanges = useMemo(
268295
() => !haveSameServerSelection(selectedServerIdsForForm, selectedServerIds),
269296
[selectedServerIdsForForm, selectedServerIds]
@@ -393,7 +420,7 @@ export function McpDeploy({
393420
setSavedValues({
394421
toolName,
395422
toolDescription,
396-
overrides: { ...parameterDescriptionOverrides },
423+
descriptions: { ...parameterDescriptions },
397424
})
398425
onCanSaveChange?.(false)
399426
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ALTER TABLE "workflow_mcp_tool" ADD COLUMN "parameter_description_overrides" json DEFAULT '{}'::json NOT NULL;
1+
ALTER TABLE "workflow_mcp_tool" ADD COLUMN "parameter_description_overrides" json DEFAULT '{}'::json NOT NULL;

0 commit comments

Comments
 (0)