MCPcopy Create free account
hub / github.com/astercloud/aster / ValidateInput

Function ValidateInput

pkg/tools/executor.go:123–141  ·  view source on GitHub ↗

ValidateInput 验证工具输入

(tool Tool, input map[string]any)

Source from the content-addressed store, hash-verified

121
122// ValidateInput 验证工具输入
123func ValidateInput(tool Tool, input map[string]any) error {
124 schema := tool.InputSchema()
125 if schema == nil {
126 return nil // 没有schema,跳过验证
127 }
128
129 // TODO: 使用jsonschema库进行验证
130 // 这里先做简单的required字段检查
131 if required, ok := schema["required"].([]any); ok {
132 for _, field := range required {
133 fieldName := field.(string)
134 if _, exists := input[fieldName]; !exists {
135 return fmt.Errorf("missing required field: %s", fieldName)
136 }
137 }
138 }
139
140 return nil
141}
142
143// ToolCallRecordBuilder 工具调用记录构建器
144type ToolCallRecordBuilder struct {

Callers

nothing calls this directly

Calls 1

InputSchemaMethod · 0.65

Tested by

no test coverage detected