diff --git a/mcp/client.go b/mcp/client.go index 0c37ff923..891fab5c3 100644 --- a/mcp/client.go +++ b/mcp/client.go @@ -1124,6 +1124,9 @@ func validateElicitArrayProperty(propName string, propSchema *jsonschema.Schema) } func validateTitledEnumEntry(entry *jsonschema.Schema) error { + if entry == nil { + return fmt.Errorf("titled enum entries must be objects") + } if entry.Const == nil { return fmt.Errorf("const is required for titled enum entries") } diff --git a/mcp/mcp_test.go b/mcp/mcp_test.go index c53e6d571..b15cd7fb0 100644 --- a/mcp/mcp_test.go +++ b/mcp/mcp_test.go @@ -1650,6 +1650,34 @@ func TestElicitationSchemaValidation(t *testing.T) { }, expectedError: "elicit schema property \"priority\" oneOf has invalid entry: const is required for titled enum entries", }, + { + name: "titled enum with null oneOf entry", + schema: &jsonschema.Schema{ + Type: "object", + Properties: map[string]*jsonschema.Schema{ + "priority": { + Type: "string", + OneOf: []*jsonschema.Schema{nil}, + }, + }, + }, + expectedError: "elicit schema property \"priority\" oneOf has invalid entry: titled enum entries must be objects", + }, + { + name: "multi select titled enum with null anyOf entry", + schema: &jsonschema.Schema{ + Type: "object", + Properties: map[string]*jsonschema.Schema{ + "priorities": { + Type: "array", + Items: &jsonschema.Schema{ + AnyOf: []*jsonschema.Schema{nil}, + }, + }, + }, + }, + expectedError: "elicit schema property \"priorities\" items has invalid entry: titled enum entries must be objects", + }, { name: "untyped property", schema: &jsonschema.Schema{