MCPcopy Create free account
hub / github.com/echoVic/blade-code / applyDefaults

Method applyDefaults

src/tools/validator.ts:99–112  ·  view source on GitHub ↗

* 应用默认值

(
    parameters: Record<string, any>,
    schema: Record<string, ToolParameterSchema>
  )

Source from the content-addressed store, hash-verified

97 * 应用默认值
98 */
99 public static applyDefaults(
100 parameters: Record<string, any>,
101 schema: Record<string, ToolParameterSchema>
102 ): Record<string, any> {
103 const result = { ...parameters };
104
105 for (const [key, paramSchema] of Object.entries(schema)) {
106 if (!(key in result) && paramSchema.default !== undefined) {
107 result[key] = paramSchema.default;
108 }
109 }
110
111 return result;
112 }
113
114 /**
115 * 清理参数(移除未定义的参数)

Callers 1

callToolMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected