Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mcp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
28 changes: 28 additions & 0 deletions mcp/mcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Loading