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

Function filterSchemaForLLM

apps/sim/tools/params.ts:825–852  ·  view source on GitHub ↗
(
  originalSchema: ToolSchema,
  userProvidedParams: Record<string, unknown>
)

Source from the content-addressed store, hash-verified

823 * Filters out user-provided parameters from tool schema for LLM
824 */
825export function filterSchemaForLLM(
826 originalSchema: ToolSchema,
827 userProvidedParams: Record<string, unknown>
828): ToolSchema {
829 if (!originalSchema || !originalSchema.properties) {
830 return originalSchema
831 }
832
833 const filteredProperties = { ...originalSchema.properties }
834 const filteredRequired = [...(originalSchema.required || [])]
835
836 // Remove user-provided parameters from the schema
837 Object.keys(userProvidedParams).forEach((paramKey) => {
838 if (isNonEmpty(userProvidedParams[paramKey])) {
839 delete filteredProperties[paramKey]
840 const reqIndex = filteredRequired.indexOf(paramKey)
841 if (reqIndex > -1) {
842 filteredRequired.splice(reqIndex, 1)
843 }
844 }
845 })
846
847 return {
848 ...originalSchema,
849 properties: filteredProperties,
850 required: filteredRequired,
851 }
852}
853
854/**
855 * Validates that all required parameters are provided

Callers 3

params.test.tsFile · 0.90
createCustomToolMethod · 0.90
buildMcpToolMethod · 0.90

Calls 1

isNonEmptyFunction · 0.85

Tested by

no test coverage detected