From 8c50299a5e52c6e8f5d927dd634a78ac23d76136 Mon Sep 17 00:00:00 2001 From: Giuseppe Coviello Date: Thu, 26 Jun 2025 12:55:21 -0400 Subject: [PATCH] Added 'Definitions' field to 'ToolInputSchema' --- mcp/tools.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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) }