MCPcopy Index your code
hub / github.com/simstudioai/sim / generateToolInputSchema

Function generateToolInputSchema

apps/sim/lib/mcp/workflow-tool-schema.ts:139–188  ·  view source on GitHub ↗
(inputFormat: InputFormatField[])

Source from the content-addressed store, hash-verified

137 * that MCP clients can use to understand tool parameters.
138 */
139export function generateToolInputSchema(inputFormat: InputFormatField[]): McpToolInputSchema {
140 const properties: Record<string, McpToolProperty> = {}
141 const required: string[] = []
142
143 for (const field of inputFormat) {
144 if (!field.name) continue
145
146 const fieldName = field.name
147 const fieldType = mapFieldTypeToJsonSchemaType(field.type)
148
149 const property: McpToolProperty = {
150 type: fieldType,
151 // Use custom description if provided, otherwise use field name
152 description: field.description?.trim() || fieldName,
153 }
154
155 // Handle array types
156 if (fieldType === 'array') {
157 if (field.type === 'file[]') {
158 property.items = {
159 type: 'object',
160 properties: {
161 name: { type: 'string', description: 'File name' },
162 url: { type: 'string', description: 'File URL' },
163 type: { type: 'string', description: 'MIME type' },
164 size: { type: 'number', description: 'File size in bytes' },
165 },
166 }
167 // Use custom description if provided, otherwise use default
168 if (!field.description?.trim()) {
169 property.description = 'Array of file objects'
170 }
171 } else {
172 property.items = { type: 'string' }
173 }
174 }
175
176 properties[fieldName] = property
177
178 // All fields are considered required by default
179 // (in the future, we could add an optional flag to InputFormatField)
180 required.push(fieldName)
181 }
182
183 return {
184 type: 'object',
185 properties,
186 required: required.length > 0 ? required : undefined,
187 }
188}
189
190/**
191 * Overlay sparse per-parameter description overrides onto a base schema produced by

Callers 5

buildTriggerRunOptionFunction · 0.90
executeDeployMcpFunction · 0.90
generateSchemaFromBlocksFunction · 0.90
McpDeployFunction · 0.90
generateToolDefinitionFunction · 0.85

Calls 2

pushMethod · 0.45

Tested by

no test coverage detected