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

Function buildParameterSchema

apps/sim/tools/params.ts:427–461  ·  view source on GitHub ↗

* Creates a tool schema for LLM with user-provided parameters excluded

(
  toolId: string,
  paramId: string,
  param: ToolParamDefinition,
  options: UserToolSchemaOptions = {}
)

Source from the content-addressed store, hash-verified

425 * Creates a tool schema for LLM with user-provided parameters excluded
426 */
427function buildParameterSchema(
428 toolId: string,
429 paramId: string,
430 param: ToolParamDefinition,
431 options: UserToolSchemaOptions = {}
432): SchemaProperty {
433 const surface = options.surface ?? 'default'
434
435 if (surface === 'copilot' && (param.type === 'file' || param.type === 'file[]')) {
436 return buildCopilotFileParameterSchema(param)
437 }
438
439 let schemaType = param.type
440 if (schemaType === 'json' || schemaType === 'any') {
441 schemaType = 'object'
442 }
443
444 const propertySchema: SchemaProperty = {
445 type: schemaType,
446 description: param.description || '',
447 }
448
449 if (param.type === 'array' && param.items) {
450 propertySchema.items = {
451 ...param.items,
452 ...(param.items.properties && {
453 properties: { ...param.items.properties },
454 }),
455 }
456 } else if (param.items) {
457 logger.warn(`items property ignored for non-array param "${paramId}" in tool "${toolId}"`)
458 }
459
460 return propertySchema
461}
462
463function buildCopilotFileParameterSchema(param: ToolParamDefinition): SchemaProperty {
464 const baseDescription =

Callers 2

createUserToolSchemaFunction · 0.85
createLLMToolSchemaFunction · 0.85

Calls 2

warnMethod · 0.65

Tested by

no test coverage detected