(toolName string, rawSchema map[string]any)
| 6 | ) |
| 7 | |
| 8 | func BuildMCPInputSchema(toolName string, rawSchema map[string]any) map[string]any { |
| 9 | props := mapFromAny(rawSchema["properties"]) |
| 10 | if len(props) == 0 { |
| 11 | return map[string]any{ |
| 12 | "description": "Empty input for tools that need no parameters.", |
| 13 | "properties": map[string]any{}, |
| 14 | "title": "_EmptyInput", |
| 15 | "type": "object", |
| 16 | } |
| 17 | } |
| 18 | required := stringSetFromAny(rawSchema["required"]) |
| 19 | defs := map[string]any{} |
| 20 | modelName := sanitizeMCPModelName(toolName) |
| 21 | out := buildMCPObjectSchema(modelName, props, required, defs) |
| 22 | if rawSchema["additionalProperties"] == false { |
| 23 | out["additionalProperties"] = false |
| 24 | } |
| 25 | if len(defs) > 0 { |
| 26 | out["$defs"] = defs |
| 27 | } |
| 28 | return out |
| 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{} |
no test coverage detected