diff --git a/mcp/tools.go b/mcp/tools.go index 3e3931b09..1374a755a 100644 --- a/mcp/tools.go +++ b/mcp/tools.go @@ -516,9 +516,10 @@ func (t Tool) MarshalJSON() ([]byte, error) { } type ToolInputSchema struct { - Type string `json:"type"` - Properties map[string]any `json:"properties,omitempty"` - Required []string `json:"required,omitempty"` + Type string `json:"type"` + Properties map[string]any `json:"properties,omitempty"` + Required []string `json:"required,omitempty"` + Definitions map[string]ToolInputSchema `json:"$defs,omitempty"` } // MarshalJSON implements the json.Marshaler interface for ToolInputSchema. @@ -535,6 +536,10 @@ func (tis ToolInputSchema) MarshalJSON() ([]byte, error) { m["required"] = tis.Required } + if len(tis.Definitions) > 0 { + m["$defs"] = tis.Definitions + } + return json.Marshal(m) }