MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / getToolInputType

Function getToolInputType

packages/server/src/services/mcp-endpoint/index.ts:46–60  ·  view source on GitHub ↗

* Determine the tool input type based on the chatflow type and flowData. * For AGENTFLOW, we look for a `startAgentflow` node and check its `startInputType` property. * If it's `formInput`, we return 'form', otherwise 'question'. * For other flow types, we default to 'question'.

(chatflow: ChatFlow)

Source from the content-addressed store, hash-verified

44 * For other flow types, we default to 'question'.
45 */
46function getToolInputType(chatflow: ChatFlow): 'question' | 'form' {
47 if (chatflow.type === 'AGENTFLOW') {
48 try {
49 const flowData: IReactFlowObject = JSON.parse(chatflow.flowData)
50 const nodes = flowData.nodes || []
51 const startNode = nodes.find((node) => node.data.name === 'startAgentflow')
52 const startInputType = startNode?.data?.inputs?.startInputType as StartInputType | undefined
53 return startInputType === 'formInput' ? 'form' : 'question'
54 } catch (error) {
55 logger.error(`Failed to parse flowData for chatflow ${chatflow.id}: ${getErrorMessage(error)}`)
56 return 'question'
57 }
58 }
59 return 'question'
60}
61
62/**
63 * Build the zod input schema parameters for the tool.

Callers 2

buildInputSchemaFunction · 0.85
chatflowCallbackFunction · 0.85

Calls 2

getErrorMessageFunction · 0.90
parseMethod · 0.65

Tested by

no test coverage detected