MCPcopy Create free account
hub / github.com/53AI/53AIHub / encodeMCPValue

Function encodeMCPValue

api/controller/mcp_output.go:17–49  ·  view source on GitHub ↗
(data any)

Source from the content-addressed store, hash-verified

15}
16
17func 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
51func encodeMCPMap(input map[string]any) map[string]any {
52 result := make(map[string]any, len(input))

Callers 6

encodeMCPToolOutputFunction · 0.85
encodeMCPMapFunction · 0.85
encodeMCPSliceFunction · 0.85
encodeMCPReflectSliceFunction · 0.85
encodeMCPReflectMapFunction · 0.85
encodeMCPIDSliceFunction · 0.85

Calls 5

encodeMCPMapFunction · 0.85
encodeMCPSliceFunction · 0.85
encodeMCPReflectSliceFunction · 0.85
encodeMCPReflectMapFunction · 0.85
IsValidMethod · 0.80

Tested by

no test coverage detected