(modelName string, props map[string]any, required map[string]struct{}, defs map[string]any)
| 29 | } |
| 30 | |
| 31 | func buildMCPObjectSchema(modelName string, props map[string]any, required map[string]struct{}, defs map[string]any) map[string]any { |
| 32 | properties := map[string]any{} |
| 33 | requiredList := []any{} |
| 34 | for propName, rawProp := range props { |
| 35 | propDef := mapFromAny(rawProp) |
| 36 | if len(propDef) == 0 { |
| 37 | continue |
| 38 | } |
| 39 | schema := convertMCPProperty(propName, propDef, modelName, defs) |
| 40 | if _, ok := required[propName]; ok { |
| 41 | properties[propName] = schema |
| 42 | requiredList = append(requiredList, propName) |
| 43 | } else { |
| 44 | properties[propName] = optionalMCPSchema(schema) |
| 45 | } |
| 46 | } |
| 47 | out := map[string]any{ |
| 48 | "properties": properties, |
| 49 | "title": modelName, |
| 50 | "type": "object", |
| 51 | } |
| 52 | if len(requiredList) > 0 { |
| 53 | out["required"] = requiredList |
| 54 | } |
| 55 | return out |
| 56 | } |
| 57 | |
| 58 | func convertMCPProperty(name string, schema map[string]any, prefix string, defs map[string]any) map[string]any { |
| 59 | field := map[string]any{} |
no test coverage detected