@@ -22,8 +22,6 @@ import {
2222 getMeaningfulWorkflowDescription ,
2323 sanitizeToolName ,
2424} from '@/lib/mcp/workflow-tool-schema'
25- import { normalizeInputFormatValue } from '@/lib/workflows/input-format'
26- import { isInputDefinitionTrigger } from '@/lib/workflows/triggers/input-definition-triggers'
2725import type { InputFormatField } from '@/lib/workflows/types'
2826import { CreateWorkflowMcpServerModal } from '@/app/workspace/[workspaceId]/settings/components/workflow-mcp-servers/components/create-workflow-mcp-server-modal'
2927import {
@@ -35,8 +33,6 @@ import {
3533 type WorkflowMcpServer ,
3634 type WorkflowMcpTool ,
3735} from '@/hooks/queries/workflow-mcp-servers'
38- import { EMPTY_SUBBLOCK_VALUES , useSubBlockStore } from '@/stores/workflows/subblock/store'
39- import { useWorkflowStore } from '@/stores/workflows/workflow/store'
4036import type { WorkflowState } from '@/stores/workflows/workflow/types'
4137
4238const logger = createLogger ( 'McpToolDeploy' )
@@ -141,48 +137,17 @@ export function McpDeploy({
141137 const deleteToolMutation = useDeleteWorkflowMcpTool ( )
142138 const updateToolMutation = useUpdateWorkflowMcpTool ( )
143139
144- const blocks = useWorkflowStore ( ( state ) => state . blocks )
145-
146- const starterBlockId = useMemo ( ( ) => {
147- for ( const [ blockId , block ] of Object . entries ( blocks ) ) {
148- if ( ! block || typeof block !== 'object' ) continue
149- const blockType = ( block as { type ?: string } ) . type
150- if ( blockType && isInputDefinitionTrigger ( blockType ) ) {
151- return blockId
152- }
153- }
154- return null
155- } , [ blocks ] )
156-
157- const subBlockValues = useSubBlockStore (
158- ( state ) => ( workflowId ? state . workflowValues [ workflowId ] : undefined ) ?? EMPTY_SUBBLOCK_VALUES
159- )
160-
161- const liveInputFormat = useMemo ( ( ) : NormalizedField [ ] => {
162- if ( ! starterBlockId ) return [ ]
163-
164- const storeValue = subBlockValues [ starterBlockId ] ?. inputFormat
165- const normalized = normalizeInputFormatValue ( storeValue ) as NormalizedField [ ]
166- if ( normalized . length > 0 ) return normalized
167-
168- const startBlock = blocks [ starterBlockId ]
169- const blockValue = startBlock ?. subBlocks ?. inputFormat ?. value
170- return normalizeInputFormatValue ( blockValue ) as NormalizedField [ ]
171- } , [ starterBlockId , subBlockValues , blocks ] )
172-
173- // The served tool is built from the DEPLOYED Start block and the server materializes overrides
174- // against it, so base the form on the deployed inputs (falling back to the live editor only while
175- // the deployed state loads) to keep the modal's defaults and override classification matching what
176- // is actually served.
177- const deployedInputFormat = useMemo ( ( ) : NormalizedField [ ] => {
140+ // The MCP tool is built from the DEPLOYED Start block and the server materializes overrides
141+ // against it; the form is gated on deployedState below, so it works purely off the deployed
142+ // snapshot (never the live editor), keeping its defaults and override classification in lockstep
143+ // with what MCP clients receive.
144+ const inputFormat = useMemo ( ( ) : NormalizedField [ ] => {
178145 const deployedBlocks = deployedState ?. blocks
179146 if ( ! deployedBlocks ) return [ ]
180147 return ( extractInputFormatFromBlocks ( deployedBlocks as Record < string , unknown > ) ??
181148 [ ] ) as NormalizedField [ ]
182149 } , [ deployedState ] )
183150
184- const inputFormat = deployedState ? deployedInputFormat : liveInputFormat
185-
186151 const [ toolName , setToolName ] = useState ( ( ) => sanitizeToolName ( workflowName ) )
187152 const [ toolDescription , setToolDescription ] = useState ( '' )
188153 const workflowDescriptionFallback = getMeaningfulWorkflowDescription (
@@ -501,7 +466,7 @@ export function McpDeploy({
501466 )
502467 }
503468
504- if ( isLoadingServers ) {
469+ if ( isLoadingServers || ! deployedState ) {
505470 return (
506471 < div className = '-mx-1 space-y-4 px-1' >
507472 < div className = 'space-y-3' >
0 commit comments