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

Function parseMCPHashIDJSON

api/controller/mcp_input.go:39–56  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

37}
38
39func parseMCPHashIDJSON(data []byte) (string, error) {
40 data = bytes.TrimSpace(data)
41 if len(data) == 0 || bytes.Equal(data, []byte("null")) {
42 return "", fmt.Errorf("ID 不能为空")
43 }
44
45 var raw string
46 if err := json.Unmarshal(data, &raw); err != nil {
47 return "", fmt.Errorf("ID 必须使用 HashID")
48 }
49 if raw == "" {
50 return "", fmt.Errorf("ID 不能为空")
51 }
52 if _, err := hashids.Decode(raw); err != nil {
53 return "", err
54 }
55 return raw, nil
56}
57
58func MCPHashIDsToInt64(ids []MCPHashID) []int64 {
59 if len(ids) == 0 {

Callers 1

UnmarshalJSONMethod · 0.85

Calls 2

ErrorfMethod · 0.80
DecodeMethod · 0.80

Tested by

no test coverage detected