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

Function BuildMCPInputSchema

tools/mcp_schema.go:8–29  ·  view source on GitHub ↗
(toolName string, rawSchema map[string]any)

Source from the content-addressed store, hash-verified

6)
7
8func 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
31func buildMCPObjectSchema(modelName string, props map[string]any, required map[string]struct{}, defs map[string]any) map[string]any {
32 properties := map[string]any{}

Callers 2

DecodeInputMethod · 0.85
ToAPISchemaMethod · 0.85

Calls 4

stringSetFromAnyFunction · 0.85
sanitizeMCPModelNameFunction · 0.85
buildMCPObjectSchemaFunction · 0.85
mapFromAnyFunction · 0.70

Tested by

no test coverage detected