MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / buildMCPObjectSchema

Function buildMCPObjectSchema

tools/mcp_schema.go:31–56  ·  view source on GitHub ↗
(modelName string, props map[string]any, required map[string]struct{}, defs map[string]any)

Source from the content-addressed store, hash-verified

29}
30
31func 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
58func convertMCPProperty(name string, schema map[string]any, prefix string, defs map[string]any) map[string]any {
59 field := map[string]any{}

Callers 2

BuildMCPInputSchemaFunction · 0.85
convertMCPPropertyFunction · 0.85

Calls 3

convertMCPPropertyFunction · 0.85
optionalMCPSchemaFunction · 0.85
mapFromAnyFunction · 0.70

Tested by

no test coverage detected