(data any)
| 15 | } |
| 16 | |
| 17 | func encodeMCPValue(data any) any { |
| 18 | if data == nil { |
| 19 | return nil |
| 20 | } |
| 21 | |
| 22 | switch v := data.(type) { |
| 23 | case map[string]any: |
| 24 | return encodeMCPMap(v) |
| 25 | case []any: |
| 26 | return encodeMCPSlice(v) |
| 27 | } |
| 28 | |
| 29 | rv := reflect.ValueOf(data) |
| 30 | if !rv.IsValid() { |
| 31 | return nil |
| 32 | } |
| 33 | |
| 34 | switch rv.Kind() { |
| 35 | case reflect.Ptr: |
| 36 | if rv.IsNil() { |
| 37 | return nil |
| 38 | } |
| 39 | return encodeMCPValue(rv.Elem().Interface()) |
| 40 | case reflect.Struct: |
| 41 | return encodeMCPValue(middleware.EncodeStructIDs(data)) |
| 42 | case reflect.Slice, reflect.Array: |
| 43 | return encodeMCPReflectSlice(rv) |
| 44 | case reflect.Map: |
| 45 | return encodeMCPReflectMap(rv) |
| 46 | default: |
| 47 | return data |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func encodeMCPMap(input map[string]any) map[string]any { |
| 52 | result := make(map[string]any, len(input)) |
no test coverage detected